Follow

How to access API functions using standalone / IPC integration

It is sometimes the case that with an improper use of API calls there is a crash or undesired exceptions of your integrating application. Often the cause is that the Navigation API service is not connected yet and you call API functions. Or you call the function like ApiNavigation.startNavigation while Sygic navigation has not been started yet.

In order to avoid such problems please consider this recommended control flow :

1. Call Api.init()
2. Call Api.connect()
3. Wait for the onServiceConnected() callback is triggered before doing any API function calls
4. Check whether the navigation is running using the isApplicationRunning() function
5. If not, call Api.show() and then wait for EVENT_APP_STARTED within the OnEvent() function
6. Now the navigation is running and you can call any API functions
7. If the navigation is terminated EVENT_APP_EXIT is generated. For API to work again you should restart with the step 4.
8. If Sygic Navigation crashes the onServiceDisconnected() callback is triggered and you need to start again from the step 2.

Please check the Getting Started example for the guidelines and full sample reference.

In the following table see the result of API calls at three different states of "connection"

API Function API not connected API Connected API connected & Navi running
Api.connect() OK OK OK
Api.show() Exception* OK OK
Api.isApplicationRunning() Exception* returns FALSE returns TRUE
Api.startNavigation() Exception* NavigationException(0) OK | NavigationException(-6,-1,-3,..)
Api.getApplicationVersion() Exception* GeneralException(0) OK
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments