*Setup and enable SDK
Overview
SDK setup is separated to 3 parts:
Initialization
Grating all required permissions
Enabling sdk
Initialize SDK
Create Settings object
For SDK version 2.2.217 and newer:
For SDK version < 2.2.217:
initialize SDK.
Grant RUNTIME permissions.
In your application you need to request runtime permissions (see list below) for the SDK to work correctly. So request them prior to enable SDK and start tracking.
Or you can just use our Permission wizard or Permissions dialog. Both of them contais all needed logic for asking required permissions and they are fully compatible with new Google politics.
Enable/disable SDK.
Befor enabling the SDK you should check are all required permissions granted. And only after that you can enable the SDK.
Following code sample shows how to do it:
If you want to disable sdk:
The following code sample shows how to logout from sdk:
Firstly, you should disable sdk and after that clear the device id.
Disable SDK after tracks uploading
There is a case when user wants to disable the sdk after trip was ended. Common case looks like this:
Subscibe to tracking events and listen to
onStopTracking
methodDisable sdk by
TrackingApi.getInstance().setEnableSdk(false)
But there is on important moment: sdk can be disabled and recorded track may not be uploaded. Because track uploading may take some time. For that purpose you can use TrackingApi.getInstance().setDisableWithUpload()
method. It will wait until all tracks will be uploaded and only after that SDK will be disabled.
When SDK is waiting to tracks uploading notification text will be changed to Waiting for the tracks uploading
Also you can override this resource on your side: <string name="tracking_notification_looking_for_tracks_upload" >Waiting for the tracks uploading</string>
Last updated