Navigation (v2.1.x - Android)

You can access an instance of NavigationManager class via Sdk.getNavigationManager method:

NavigationManager navigationManager = sdk.getNavigationManager();

Navmii SDK generates various navigation events. To be able to handle these events make one of your classes implement the NavigationListener interface and add an instance of this class to NavigationManager listeners via addNavigationListener method:

navigationManager.addNavigationListener(listener);

You also can add multiple listeners to NavigationManager instance. To detach a listener from NavigationManager instance use removeNavigationListener method.

These navigation events are:

  • update of navigation information (see Navigation Info section)
  • change of country of current location
  • demo route start
  • demo route stop

Navmii SDK allows you to demonstrate the way the real-time traverse of the route will look like on the screen. When the route is calculated, use startDemoRoute and stopDemoRoute methods. Use isDemoRouteActive method to find out if the demo route is still in progress.

// Starts demo route
navigationManager.startDemoRoute();
// Stops demo route
navigationManager.stopDemoRoute();

This is an example of handling demo route start and finish in NavigationListener interface implementation:

    // Logs out messages on demo route start and finish
    @Override
    public void onDemoRouteStarted() {
        Log.i("NavigationListener", "onDemoRouteStarted");
    }

    @Override
    public void onDemoRouteFinished() {
        Log.i("NavigationListener", "onDemoRouteFinished");
    }

Navmii SDK also creates a bitmap image representing traffic on the current route. To be able to receive this image when it updates, make one of you classes implement the TrafficOnRouteImageListener interface and add an instance of this class to NavigationManager's "traffic on route image" listeners:

navigationManager.addTrafficOnRouteImageListener(listener);

To detach a "traffic on route image" listener use removeTrafficOnRouteImageListener method.

@Override
void onTrafficOnRouteImageUpdated(Bitmap bitmap) {
    // handle the image
}

When navigating on the route you can get a NavigationInfo instance from NavigationManager. This object will contain the following information:

  • current road information
  • speed limit in km/h
  • user's current speed in km/h
  • country information

To understand how road information is presented in the SDK please refer to Road Info section. Here is an example of code giving you the idea how to retrieve this information:

NavigationInfo navigationInfo = navigationManager.getNavigationInfo();
Log.i("NavigationInfo", String.format("current road name - %s", navigationInfo.getCurrentRoadInfo().getName()));
Log.i("NavigationInfo", String.format("speed limit - %s kmh", navigationInfo.getSpeedLimit()));
Log.i("NavigationInfo", String.format("current speed - %s kmh", navigationInfo.getCurrentSpeed()));
Log.i("NavigationInfo", String.format("country - %s", navigationInfo.getCountry().getName()));

 A RoadInfo instance contains the following information on a road:

  • road name
  • route number
  • road usage
  • road class

Form of way is represented as FormOfWay enum with this set of values:

  • COMMON
  • RAMP
  • ROUNDABOUT
  • FERRY
  • UNDEFINED

An example of code extracting this information from RoadInfo instance can look like this:

RoadInfo roadInfo = navigationInfo.getCurrentRoadInfo();
Log.i("NavigationInfo", String.format("road name - %s", roadInfo.getName()));
Log.i("NavigationInfo", String.format("route number - %s", roadInfo.getRouteNumber()));
Log.i("NavigationInfo", String.format("road usage - %s", roadInfo.getUsage()));
Log.i("NavigationInfo", String.format("road class - %s", roadInfo.getRoadClass()));