Provide way guide(Android)

How do i add directions such as turn left, turn right etc. on android using graphhopper?

If you mean the turn instructions you can get them from the routing result, see documentation for the API.

Hello, I’ve added the code here. But it crashes and no error message is displayed. Secondly, i’ve added it onPostExecute() but it throws an error of java.lang.IllegalArgumentException: To access instructions you need to enable creation before routing

protected PathWrapper doInBackground(Void… v) {
StopWatch sw = new StopWatch().start();
GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon).
put(Routing.INSTRUCTIONS, “false”);
GHResponse resp = hopper.route(req);
time = sw.stop().getSeconds();

            InstructionList il = resp.getBest().getInstructions();
            for(Instruction instruction : il) {
            return resp.getBest();

You can enable the instructions by removing the:

req.getHints().put(Routing.INSTRUCTIONS, "false");

For any crash you can have a look at Android logcat for any exceptions.

Hi, it works! But how do i display turn left, turn right, etc.? I tried .getName but it only displays the street names

You can look at other getters in Instruction class, like getTurnDescription etc.

1 Like

thank you! At first, i was not sure on how to initialize the Translation but a few google search help.