Navigation Warnings

The Sygic Android SDK supports navigation on pedestrian and car routes. Using this feature, your app can check the current device position against a calculated route and provide just-in-time navigational instructions, both as visual and voice instructions. Turn-by-Turn Navigation Mode, which takes the calculated route and matches the current position against the route is supported for walking and driving.

While navigating, application can register a listener for warning notifications and display all of these notifications. All the types of notifications are listed in NavigationManager class. The following table shows the name of the available listeners and the information provided them.

Listener name Function
OnCurrentStreetListener Whether the current street has changed
OnDirectionListener Whether the direction has chnaged
OnSpeedLimitListener Whether the user has exceeded the speed limit
OnNaviSignListener Whether the signpost has updated
OnRadarListener Whether a speedcamera is ahead
OnRailwayListener Whether a railway crossing is ahead
OnHighwayExitListener Whether a highway exit is ahead
OnWaypointPassedListener Whether the vehicle passed by a waipoint
OnTransportModeListener Whether the transport mode has changed (from car to pedestrian for example)
OnRouteInfoListener Whether the on route info has changed
OnTrafficDataListener Whether the traffic data has updated

Registering listener for every type has following pattern:

// create listener
mOnCurrentStreetListener = new NavigationManager.OnCurrentStreetListener() {
    @Override
    public void onCurrentStreetChanged(final StreetInfo info) {
        // info about changed value
        Log.d("TAG", "StreetName: " + info.getStreetName());
        Log.d("TAG", "RoadNumber: " + info.getRoadNumber());
        // ...
    }
};

// register listener
NavigationManager.getInstance().addOnCurrentStreetListener(mOnCurrentStreetListener);

Don't forget to unregister listener when you don't need it.

NavigationManager.getInstance().removeOnCurrentStreetListener(mOnCurrentStreetListener);

Map Matching During Navigation

Map Matching is automatically enabled in both navigation mode and tracking mode. In simulation mode, the map-matched position is simulated along the route with a user-defined speed.

Voice Instructions

Voice instructions are available in the Sygic SDK as voice packages. Voice packages are available in two forms: pre-packaged or downloadable through the voice catalog. You can set a voice package to be used for navigational instructions.

The Sygic SDK supports two types of voice packages: text-to-speech or pre-recorded. Pre-recorded voice skins provide basic maneuver instructions, such as "turn right in 100 meters", while text-to-speech voices also support spoken street names, such as "turn right in 100 meters onto Wall Street".

Following code shows, how to get the list of installed voices and setting the voice:

VoiceManager.getInstance().getInstalledVoices(new VoiceManager.InstalledVoicesCallback() {
    @Override
    public void onInstalledVoiceList(final List<VoiceEntry> voices, @NonNull final OperationStatus status) {
        VoiceManager.getInstance().setVoice(voices.get(0));
    }
});

To get all available voices, you call VoiceDownload.getAvailableVoices():

VoiceDownload voiceDownload = new VoiceDownload();
voiceDownload.getAvailableVoiceList(new VoiceDownload.AvailableVoicesCallback() {
    @Override
    public void onAvailableVoiceList(final List<VoiceEntry> voiceEntries, @NonNull final OperationStatus operationStatus) {
        for (final VoiceEntry entry : voiceEntries) {
            String name = entry.getName();
            String language = entry.getLanguage();
            boolean tts = entry.isTts();
            switch (entry.getStatus()) {
                case VoiceEntry.VoicePackageStatus.NotInstalled:
                    //...
                    break;
                case VoiceEntry.VoicePackageStatus.Installed:
                    //...
                    break;
                default:
                    //...
            }
        }
    }
});

Then you can download voices.

 voiceDownload.addVoiceInstallationListener(new VoiceInstallListener() {
     @Override
     public void onVoiceInstallProgress(VoiceEntry voice, long bytesDownloaded, long totalBytes) {

     }

     @Override
     public void onVoiceInstallFinished(final VoiceEntry voice, @NonNull final OperationStatus status) {

     }

     @Override
     public void onVoiceUninstallFinished(final VoiceEntry voice, @NonNull final OperationStatus status) {

     }
});

 voiceDownload.installVoice(voice); // entry is an object returned in onAvailableVoiceList

This is a list of the potential TTS languages that are supported. Actual audio playback depends on the supported languages in the user's installed version of Android.

  • English (US)
  • English (UK)
  • French (France)
  • French (Canada)
  • German
  • Spanish (Spain)
  • Spanish (Mexico)
  • Indonesian
  • Italian
  • Norwegian
  • Portugese (Portugal)
  • Portugese (Brazil)
  • Russian
  • Swedish
  • Finnish
  • Danish
  • Korean
  • Chinese (Taiwanese Mandarin)
  • Turkish
  • Czech
  • Polish

Traffic

Traffic information show traffic incidents on the map. Traffic visualization requires a network data connection to download real time traffic information. However, traffic information may continue to be displayed thereafter without a connection until the traffic events expire or the visibility is toggled.

Traffic information

Signposts

Signs represent textual and graphic information which are along the route. The information is always represented as text or pictogram. Signpost information may be used for route guidance and map display. A navigation system may prefer using the signpost text rather than the street/ramp name as the latter may not always match what is on the sign in reality and may confuse a user. The signpost feature supports the user navigating through complex situations and provides a conformation for a maneuver by presenting the same direction information as shown on the street signs in reality.

Based on the map attributes, the Sygic Android Mobile SDKs aggregate the following information into a Signpost object:

  • Route number
  • Exit number
  • Exit name
  • Pictogram
  • Place name
  • Background color
  • Text color

Following example shows, how to get these information from the data structure, which the Android SDK offers.

package com.sygic.sdk.gettingstarted;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

import com.sygic.sdk.navigation.NavigationManager;
import com.sygic.sdk.navigation.warnings.NaviSignInfo;

import java.util.ArrayList;
import java.util.List;

public class SignpostFragment extends Fragment implements NavigationManager.OnNaviSignListener {

    private NavigationManager mManager;

    @Override
    public void onCreate(@Nullable final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mManager = NavigationManager.getInstance();
        mManager.addOnNaviSignListener(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        mManager.removeOnNaviSignListener(this);
    }

    // ....

    @Override
    public void onNaviSignChanged(@NonNull final List<NaviSignInfo> list) {
        if (list.isEmpty()) {
            return;
        }

        final NaviSignInfo naviSignInfo = list.get(0);
        final int textColor = naviSignInfo.getTextColor();
        final int backgroundColor = naviSignInfo.getBackgroundColor();
        final int distanceToSignpost = naviSignInfo.getDistance();

        final List<String> titles = new ArrayList<>();
        final List<String> roadNumbers = new ArrayList<>();
        final List<String> exits = new ArrayList<>();
        final List<String> exitNumbers = new ArrayList<>();

        for (NaviSignInfo.SignElement signElement : naviSignInfo.getSignElements()) {
            switch (signElement.getElementType()) {
                case NaviSignInfo.SignElement.SignElementType.PlaceName:
                case NaviSignInfo.SignElement.SignElementType.StreetName:
                case NaviSignInfo.SignElement.SignElementType.OtherDestination:
                    titles.add(signElement.getText());
                    break;
                case NaviSignInfo.SignElement.SignElementType.RouteNumber:
                    roadNumbers.add(signElement.getText());
                    break;
                case NaviSignInfo.SignElement.SignElementType.ExitName:
                    exits.add(signElement.getText());
                    break;
                case NaviSignInfo.SignElement.SignElementType.ExitNumber:
                    exitNumbers.add(signElement.getText());
                    break;
            }
        }

        // do something with the collected data
    }
}

Directions

To provide more detailed information in signpost, you can display the direction which the user should follow. The Directions feature allows developers to define and display routes between a start and a destination point within their application. NavigationManager.OnDirectionListener can return following information:

  • Direction distance
  • Next direction distance
  • Maneuver type - see the all available ManeuverTypes
  • Road name
  • Next road name

Following example shows, how to get these information from the data structure, which the Android SDK offers.

package com.sygic.sdk.gettingstarted;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;

import com.sygic.sdk.navigation.NavigationManager;
import com.sygic.sdk.navigation.warnings.DirectionInfo;
import com.sygic.sdk.route.RouteManeuver;

public class DirectionFragment extends Fragment implements NavigationManager.OnDirectionListener {

    private NavigationManager mManager;

    @Override
    public void onCreate(@Nullable final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mManager = NavigationManager.getInstance();
        mManager.addOnDirectionListener(this);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();

        mManager.removeOnDirectionListener(this);
    }

    // ....

    @Override
    public void onDirectionInfoChanged(@NonNull final DirectionInfo directionInfo) {
        final int distance = directionInfo.getDistance();
        final int nextDistance = directionInfo.getNextDistance();

        final RouteManeuver primaryManeuver = directionInfo.getPrimary();
        if (primaryManeuver != null) {
            final int type = primaryManeuver.getType();
            final String roadName = primaryManeuver.getRoadName();
            final String nextRoadName = primaryManeuver.getNextRoadName();
            Log.d("directions", "direction of type " + type + " on the road " + roadName + ". Next road is " + nextRoadName);
        }

    }
}

With these data now you just have to draw them into your view and create your own signposts. For example like this:

Signpost

Junction Info

Junction info is one of our advanced safety features. When you are approaching a complex highway intersection, a JunctionInfo object will be set in a OnNaviSignListener. It contains info about lanes both continuing on highway and on the exit. You can then display this information, eg. as full screen diagram.

mNaviSignListener = new NavigationManager.OnNaviSignListener() {

    @Override
    public void onNaviSignChanged(@NonNull final List<NaviSignInfo> list) {
        for (final NaviSignInfo naviSignInfo : list) {
            JunctionInfo junctionInfo = naviSignInfo.getJunctionInfo();

            if (junctionInfo.getAreaType() != JunctionInfo.AreaType.Unknown) {
                @JunctionInfo.TurnDirection int turnDirection = junctionInfo.getTurnDirection();
                @JunctionInfo.TurnType int turnType = junctionInfo.getTurnType();
                int fromLanes = junctionInfo.getFromLanesCount();
                int leftLanes = junctionInfo.getToLeftLanesCount();
                int rightLanes = junctionInfo.getToRightLanesCount();

                // display junction info

                return;
            }
        }

        // no junction info
    }
};

When you have JunctionInfo with getFromLanesCount() == 5, getToLeftLanesCount() == 4, getToRightLanesCount() == 2, it can be displayed as shown below.

Junction

Speed Limit

Speed limits indicate the legal speed for a vehicle. You can get the value either in mph or in km/h. You can register OnSpeedLimitListener to receive events about speed limit change. The class containing information about speed limit is SpeedLimitInfo.

mSeedLimitListener = new NavigationManager.OnSpeedLimitListener() {

    @Override
    public void onSpeedLimitInfoChanged(@NonNull final SpeedLimitInfo speedLimitInfo) {
        int speedLimit = speedLimitInfo.getSpeedLimit(SpeedLimitInfo.SpeedUnits.Kilometers);
        int currentSpeed = speedLimitInfo.getCurrentSpeed(SpeedLimitInfo.SpeedUnits.Kilometers);

        if (speedLimit < currentSpeed) {
            // vehicle is speeding
        }

        int nextSpeedLimit = speedLimitInfo.getNextSpeedLimit(SpeedLimitInfo.SpeedUnits.Kilometers);
        int distance = speedLimitInfo.getNextSpeedLimitDistance();

        if (speedLimit != nextSpeedLimit) {
            // eg. show warning about limit change
        }

        @SpeedLimitInfo.SpeedUnits int countrySpeedUnits = speedLimitInfo.getCountrySpeedUnits();
        int naturalLimit = speedLimitInfo.getSpeedLimit(countrySpeedUnits);

        // natural limit is in country's natural units, so rounding and decimals can be avoided
    }
};

Report Incident

Our Speed Camera database consists of more than 60 000 fixed speed cameras, red light cameras and average speed checks all over the world. On top of that, the community reports tens of thousands of additional mobile speed cameras and police checks every day. So, if you want to help to make our database bigger, use following example to report an incident. As parameter you can choose in which direction it happened on the road.

NavigationManager.getInstance().reportIncident(position, Incident.Type.Incident, Incident.Direction.MyDirection);