Route sharing

The SharingManager class in the Navmii SDK is responsible for managing the sharing of routes. This includes starting and stopping the route sharing process and checking if the route sharing is currently active.

An instance of the SharingManager can be retrieved using the Sdk.getInstance().getSharingManager() method.

The SharingManager class provides the following functionality:

  • Starting route sharing using the startRouteSharing method.

  • Stopping route sharing using the stopRouteSharing method.

  • Checking if route sharing is active using the isRouteSharingStarted method.

Listening for route sharing events

The RouteSharingListener is an abstract class that handles route sharing events. Implement this listener to receive notifications about the status of the route sharing.

  • onRouteSharingStarted(String url): Called once route sharing is started. The URL parameter will contain a link to the webpage where the shared route can be viewed.

  • onRouteSharingFailed(RouteSharingError error): Called if route sharing fails.

  • onRouteSharingStopped(): Called once route sharing is stopped.

Example:

SharingManager manager = Sdk.getInstance().getSharingManager(); RouteSharingListener listener = new RouteSharingListener() { @Override public void onRouteSharingStarted(String url) { Log.d("RouteSharing", "Route sharing started. URL: " + url); } @Override public void onRouteSharingFailed(RouteSharingError error) { Log.e("RouteSharing", "Route sharing failed. Error: " + error); } @Override public void onRouteSharingStopped() { Log.d("RouteSharing", "Route sharing stopped."); } }; ApiCredentials credentials = new ApiCredentials.Builder() .setAccountId(...) .setPassword(...) .setEmailId(...) .build(); manager.startRouteSharing(credentials, listener); ... // Stop route sharing when necessary manager.stopRouteSharing(); ... // Check if route sharing is active boolean isSharing = manager.isRouteSharingStarted(); Log.d("RouteSharing", "Is route sharing active: " + isSharing);