Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Guides
Displaying Turn Directions

Displaying Turn Directions

While your app is navigating the user, you will also want to send turn by turn directions. This is useful for if your app is in the background or if the user is in the middle of a phone call, and gives the system additional information about the next maneuver the user must make.
When your navigation app is guiding the user to a specific destination, you can provide the user with visual and audio turn-by-turn prompts. These prompts will be presented even when your SDL app is backgrounded or a phone call is ongoing.
While your app is navigating the user, you will also want to send turn by turn directions. This is useful if your app is in the background or if the user is in the middle of a phone call, and gives the system additional information about the next maneuver the user must make.

To create a turn-by-turn direction that provides both a visual and audio cues, a combination of the ShowConstantTBT and AlertManeuver RPCs must should be sent to the head unit.

Note

If the connected device has received a phone call in the vehicle, the AlertManeuver is the only way for your app to inform the user of the next turn.

Visual Turn Directions

The visual data is sent using the ShowConstantTBT RPC. The main properties that should be set are navigationText1, navigationText2, and turnIcon. A best practice for navigation apps is to use the navigationText1 as the direction to give (i.e. turn right) and navigationText2 to provide the distance to that direction (i.e. 3 mi.).

Audio Turn Directions

The audio data is sent using the AlertManeuver RPC. When sent, the head unit will speak the text you provide (e.g. In 3 miles turn right).

Sending Audio and Visual Turn Directions

ShowConstantTbt turnByTurn = new ShowConstantTbt()
    .setNavigationText1("Turn Right")
    .setNavigationText2("3 mi")
    .setTurnIcon(turnIcon);
turnByTurn.setOnRPCResponseListener(new OnRPCResponseListener() {
    @Override
    public void onResponse(int correlationId, RPCResponse response) {
        if (!response.getSuccess()){
            DebugTool.logError(TAG, "onResponse: Error sending TBT");
            return;
        }

            AlertManeuver alertManeuver = new AlertManeuver()
                .setTtsChunks(Collections.singletonList(new TTSChunk("In 3 miles turn right", SpeechCapabilities.TEXT)));
            alertManeuver.setOnRPCResponseListener(new OnRPCResponseListener() {
                @Override
                public void onResponse(int correlationId, RPCResponse response) {
                    if (!response.getSuccess()){
                        DebugTool.logError(TAG, "onResponse: Error sending AlertManeuver");
                    }
                }
            });
            sdlManager.sendRPC(alertManeuver);
        }
    });
sdlManager.sendRPC(turnByTurn);

Remember when sending a Image, that the image must first be uploaded to the head unit with the FileManager.

Clearing the Turn Directions

To clear a navigation direction from the screen, send a ShowConstantTbt with the maneuverComplete property set to true. This will also clear the accompanying AlertManeuver.

ShowConstantTbt turnByTurn = new ShowConstantTbt()
    .setManeuverComplete(true);
turnByTurn.setOnRPCResponseListener(new OnRPCResponseListener() {
    @Override
    public void onResponse(int correlationId, RPCResponse response) {
        if (!response.getSuccess()){
            DebugTool.logError(TAG, "onResponse: Error sending TBT");
        }
    }
});
sdlManager.sendRPC(turnByTurn);
View on GitHub.com
Previous Section Next Section