Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

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 Both Audio and Visual Turn Directions

Image turnIcon =  <#Create Image#>

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

        AlertManeuver alertManeuver = new AlertManeuver();
        alertManeuver.setTtsChunks(TTSChunkFactory.createSimpleTTSChunks("In 3 miles turn right"));
        alertManeuver.setOnRPCResponseListener(new OnRPCResponseListener() {
            @Override
            public void onResponse(int correlationId, RPCResponse response) {
                if (!response.getSuccess()){
                    Log.e(TAG, "onResponse: Error sending AlertManeuver");
                }
            }

            @Override
            public void onError(int correlationId, Result resultCode, String info){
                Log.e(TAG, "onError: "+ resultCode+ " | Info: "+ info );
            }
        });
        sdlManager.sendRPC(alertManeuver);
    }

    @Override
    public void onError(int correlationId, Result resultCode, String info){
        Log.e(TAG, "onError: "+ resultCode+ " | Info: "+ info );
    }
});
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();
turnByTurn.setManeuverComplete(true);
turnByTurn.setOnRPCResponseListener(new OnRPCResponseListener() {
    @Override
    public void onResponse(int correlationId, RPCResponse response) {
        if (!response.getSuccess()){
            Log.e(TAG, "onResponse: Error sending TBT");
        }
    }

    @Override
    public void onError(int correlationId, Result resultCode, String info){
        Log.e(TAG, "onError: "+ resultCode+ " | Info: "+ info );
    }
});
sdlManager.sendRPC(turnByTurn);
View on GitHub.com
Previous Section Next Section