Work with DriveSession
Drive session is the most important component of our SDK. It serves map-matching, navigation, alerts and other important services.
As with our other service components, the user creates the drive session instances via a factory.
By default, some of its services like the position service will automatically run once the drive session instance been created. Some of its services disabled by default, user need to call related drive session API to enable it. For example, with enableAlert member function call during lifecycle of drive session instance to enable or disable alert service, or calling enableADAS to enable or disable ADAS service.
There is another important concept named event hub which using for communicating between each service and the SDK user during runtime, SDK user can get the event hub instance with getEventHub function call:
Position Service
As the name states, position service provides the core positional service. It continually informs the user of detailed information like: the road name, speed limit, driving side of the street, etc... It also provides the accurately map-matched GPS position with high frequency (4Hz by default). Internally in our SDK, it is directly retrieving GPS location via the Android system API. SDK user does not need to perform any further action except grant/ensure user permission ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION.
The position service automatically runs once the drive session instance been created. To monitor events broadcasting from position service, one needs to create a PositionEventListener instance and add it to the event hub of the drive session:
Navigation Service
The SDK provides turn-by-turn audio-ready instructions once the user gets a route and starts a navigation session. Meanwhile, the SDK will automatically re-calculate the navigation route for you when one or more of the following situation happens:
- The user deviates from current route
- There exists some critical traffic incidents or heavy traffic situations ahead
- Illegal turn encountered ahead
To start a new navigation session with startNavigation function call (assuming client already owns an instance of drive session):
During an active navigation session, the SDK will broadcast navigation signals (at 1Hz frequenct) informing each other on the status of current navigation session, following information included:
- distance to turn
- turn type(icon) of current step
- next street name
- next-next street name(if available)
- highway EXIT label and other signpost strings(if availible)
- lane patterns(if available)
- junction view image(if available)
- ETA of upcoming stop or destination
To monitor these kinds of navigation events, the user needs to create a navigation event listener and register it to the drive session event hub. The following sample code illustrates registering a navigation event listener (assuming client already owns instance of drive session):
Anytime navigation has been automatically re-routed, the client will be informed via the navigation event listener(see NavigationEventListener.onNavigationRouteUpdated).
During a navigation session, the user can change the current route. For example, adding, deleting or modifying stops and changing route styles. Here is the sample API call (assuming client already owns navigation session instance):
To stop the current navigation session, just call SDK api NavigationSession.stopNavigation. Once the navigation session been stopped, all resource binding together with the navigation session instance will be cleaned. The client won't recieve navigation related events anymore.
ADAS(Advanced Driving Assistance System) service
The SDK provides map-matching with high accuracy ADAS information such as the speed limit, road type, slope and curvature, traffic speed etc... while driving (regardless of whether in active navigation or free-driving). By default, ADAS service will not be activated until user enables ADAS service explicitly. One can call enableADAS to enable or disable the ADAS service. Once ADAS service been activated, drive session will broadcast ADAS massages with high frequency (4Hz by default). The following code segment illustrates how to enable ADAS service and receive ADAS messages: