Methods for Android app

Log in/ Log out

Log in

val trackingApi = TrackingApi.getInstance()
if (trackingApi.isAllRequiredPermissionsAndSensorsGranted()) {
   trackingApi.setDeviceID("YOUR DEVICE ID") // DEV_ID = DeviceToken
   trackingApi.setEnableSdk(true) 
}

Log out

trackingApi.setEnableSdk(false) //disable SDK
trackingApi.clearDeviceID() //Clear DeviceToken

Enable/Disable SDK


Enable SDK

val trackingApi = TrackingApi.getInstance()
if (trackingApi.isAllRequiredPermissionsAndSensorsGranted()) {
   trackingApi.setDeviceID("DeviceToken") // User DeviceToken
   trackingApi.setEnableSdk(true) //false to disable SDK
}

Disable SDK

trackingApi.setEnableSdk(false)

Disable SDK with enforced trip uploading

There is a case when the user wants to disable the SDK once the trip was finished. In a common case we have the following steps:

  1. Subscribe to tracking events and listen to onStopTracking method
  2. Disable SDK by TrackingApi.getInstance().setEnableSdk(false)

But there is an important moment: when you use the approach described above, SDK may be disabled before all trips were uploaded. As a result, you won't have access to this data until you enable SDK and the user makes a new trip.
However, there is an option to handle that. Please use
TrackingApi.getInstance().setDisableWithUpload()

method to enforce trip uploading. With this method, SDK will be disabled after it delivers all data to the platform.
When SDK is waiting for tracks uploading, the push-notification text will be changed to Waiting for the tracks uploading

πŸ“˜

Asset Customisation

You can customize the notification resources

<string name="tracking_notification_looking_for_tracks_upload" >Waiting for the tracks uploading</string>

Enable/ Disable Tracking


These methods are not applicable to Android. Instead, please use methods Enable/Disable SDK

Manual start/ stop tracking


Manual start

TrackingApi.getInstance().startTracking()

Manual stop

TrackingApi.getInstance().stopTracking()

Enable Aggressive Heartbeats


This method is not applicable to Android SDK

Enable Ads ID

Set Ads ID

TrackingApi.getInstance().setAdvertisingId("<id>")

Remove Ads ID

TrackingApi.getInstance().clearAdvertisingId()

Connect Bluetooth OBD


Please refer to a special page that we created for the Bluetooth OBD integration
Setting up for Android app

Create a new tag

πŸ“˜

The detailed information about using Tags is available here

fun addFutureTrackTag(tag: String?, source: String? = null)

*Get tags

fun getFutureTrackTags()

*Remove a tag

fun removeFutureTrackTag(tag: String?)

*Remove all tags

fun removeAllFutureTrackTags()

Check current track state

/**
* Check current running track state. True - track is recording.
*/
fun isTracking(): Boolean

Get tracks


**
* Returns tracks information. (tracks are cached in local DB)
*
* @param locale    Language in which tracks are to arrive.
* @param startDate Start date format "yyyy-MM-dd'T'HH:mm:ss ZZ" or null.
* @param endDate   End date format "yyyy-MM-dd'T'HH:mm:ss ZZ" or null.
* @param offset    Offset numb for pagination.
* @param count     Count items for pagination.
*/
// IMPORTANT! Do not call this method in the Main thread. 
fun *getTracks(locale: Locale,
             startDate: String,
             endDate: String,
             offset: Int,
             count: Int): Array<Track>

Response

Array of
class Track(
       /**
        * The start address.
        */
       var addressStart: String?,

       /**
        * The end address.
        */
       var addressEnd: String?,

       /**
        * The start date in "yyyy-MM-dd'T'HH:mm:ss ZZ" format.
        */
       var endDate: String?,

       /**
        * The end date in "yyyy-MM-dd'T'HH:mm:ss ZZ" format.
        */
       var startDate: String?,

       /**
        * The unique trip id.
        */
       var trackId: String?,

       /**
        * The count of sharp acceleration.
        */
       var accelerationCount: Int,

       /**
        * The count of sharp braking.
        */
       var decelerationCount: Int,

       /**
        * The distance trip in km.
        */
       var distance: Double,

       /**
        * The trip duration.
        */
       var duration: Double,

       /**
        * The trip rating. Range 1..5
        */
       var rating: Double,

       /**
        * The trip phone usage in minutes.
        */
       var phoneUsage: Double,

       /**
        * The trip type.
        * See also [TripOriginDictionary.code]
        */
       var originalCode: String?,

       /**
        * The trip type has changed. If false - origin trip type can be changed. If false - can't be changed.
        * [TripOriginDictionary.code]
        */
       var hasOriginChanged: Boolean,

       /**
        * Total distance travelled(in km) while exceeding speed limit over for 10 to 20 km/h
        */
       var midOverSpeedMileage: Double,

       /**
        * Total distance travelled(in km) while exceeding the speed limit over for 20 km/h or more.
        */
       var highOverSpeedMileage: Double,

       /**
        * Driving tips.
        */
       var drivingTips: String?,
       var shareType: String?,
       var cityStart: String?,
       var cityFinish: String?
 var ratingCornering: Double,
 var ratingAcceleration: Double,
 var ratingBraking: Double,
 var ratingSpeeding: Double,
 var ratingPhoneUsage: Double,
 var ratingTimeOfDay: Double,
 var addressStartParts: AddressParts?,
 var addressFinishParts: AddressParts?,

/**
* List of tags.
*/
val tags: Array<TrackTag>?
)
data class AddressParts(
       var countryCode: String?,
       var country: String?,
       var county: String?,
       var postalCode: String?,
       var state: String?,
       var city: String?,
       var distinct: String?,
       var street: String?,
       var house: String?
)
data class TrackTag(
       /**
        * Tag name.
        */
       var name: String? = null,
       /**
        * Source type. Maybe: "Sdk", "UserApp".
        */
       var sourceType: String? = null,
       /**
        * Source. For ex. App module (optional)
        */
       var source: String? = null
) {

       override fun toString(): String {
               return "TrackTag(name=$name, sourceType=$sourceType,
source=$source)"
       }
}

Get trip details

/**
* Returns detailed track information. (track details are cached in local DB)
*
* @param locale  Language in which track are to arrive. Maybe English, Russian, Spanish, Portugal 
* @param trackId  Track id.
*/s
// IMPORTANT! Do not call this method in the Main thread. 
fun *getTrackDetails(trackId: String, locale: Locale): TrackDetail

Response

class TrackDetails(
       /**
        * The start address.
        */
       var addressStart: String?,

       /**
        * The end address.
        */
       var addressEnd: String?,

       /**
        * The end date in "yyyy-MM-dd'T'HH:mm:ss ZZ" format.
        */
       var endDate: String?,

       /**
        * The start date in "yyyy-MM-dd'T'HH:mm:ss ZZ" format.
        */
       var startDate: String?,
       /**
        * The unique trip id.
        */
       var trackId: String?,

       /**
        * The count of sharp acceleration.
        */
       var accelerationCount: Int,

       /**
        * The count of sharp braking.
        */
       var decelerationCount: Int,

       /**
        * The distance trip in km.
        */
       var distance: Double,

       /**
        * The duration trip in horse.
        */
       var duration: Double,

       /**
        * The trip rating. Range 1..5
        */
       var rating: Double,

       /**
        * The trip phone usage minutes.
        */
       var phoneUsage: Double,

       /**
        * The trip type.
        * See also [TripOriginDictionary.code]
        */
       var originalCode: String?,

       /**
        * The trip type has changed. If false - origin trip type can be changed. If false - can't be changed.
        * [TripOriginDictionary.code]
        */
       var hasOriginChanged: Boolean,

       /**
        * Total distance travelled(in km) while exceeding speed limit over for 10 to 20 km/h
        */
       var midOverSpeedMileage: Double,

       /**
        * Total distance travelled(in km) while exceeding the speed limit over for 20 km/h or more.
        */
       var highOverSpeedMileage: Double,

       /**
        * List trip points. Usually used to build a route on the map.
        */
       var points: Array<TrackPoint>?,

       /**
        * Driving tips.
        */
       var drivingTips: String?,
       var shareType: String?,
       var cityStart: String?,
       var cityFinish: String?,
 var ratingCornering: Double,
 var ratingAcceleration: Double,
 var ratingBraking: Double,
 var ratingSpeeding: Double,
 var ratingPhoneUsage: Double,
 var ratingTimeOfDay: Double,
 var addressStartParts: AddressParts?,
 var addressFinishParts: AddressParts?,

/**
* List of tags.
*/
val tags: Array<TrackTag>?
)
data class TrackTag(
       /**
        * Tag name.
        */
       var name: String? = null,
       /**
        * Source type. Maybe: "Sdk", "UserApp".
        */
       var sourceType: String? = null,
       /**
        * Source. For ex. App module (optional)
        */
       var source: String? = null
) {

       override fun toString(): String {
               return "TrackTag(name=$name, sourceType=$sourceType,
source=$source)"
       }
}

Change transportation type

/**
* Method allows you to change thet type of track to a type from the dictionary.
* See also [getTrackOriginDict]
*
* @param trackToken Track Id
* @param newCode    New track type code from track origin dictionary.
*/
fun *changeTrackOrigin(trackToken: String, newCode: String)

Dictionary:

  • OriginalDriver
  • Passenger
  • Bus
  • Motorcycle
  • Train
  • Taxi
  • Bicycle
  • Other