Quick Start

Getting Started / Android

Setup the MOVE SDK

The Android MOVE SDK must be initialized by adding MoveSdk.init() at the first line in your Android Application class (onCreate). This instance can then be used to control MOVE SDK services (check API Interface for more details).

After the MOVE SDK has been initialized you also want to add notifications, listeners or activate additional features.

Also you have to configure the MOVE SDK before you are able to call .setup(...).

In order to successfully initialize and run the MOVE SDK, the user's MoveAuth must already be fetched with the MOVE Admin API and the required permissions must be granted (Permission Handling). If the provided MoveAuth is invalid, the MOVE SDK will not initialize. If the required permissions are missing, the MOVE SDK State will change to READY. Additionally the missing permission will be presented by MoveServiceFailure and/or by MoveServiceWarning.

The initialization of the MOVE SDK is asynchronous and you will be notified regarding state changes with the MoveStateListener. On successful initialization the MoveSdkState changes to READY.

To be able to use the MOVE SDK, several permission need to be granted. This is described in Permission Handling.

Now that there is an instance of the MOVE SDK, the detection may be started with startAutomaticDetection(), which should lead to the state RUNNING of the MOVE SDK.

The MOVE SDK is collecting data only when inRUNNINGstate.

Code example

// in your application class

override fun onCreate() {
   // init the MOVE SDK
   val moveSdk = MoveSdk.init(this)   
   
   super.onCreate()

   // Example of adding some notifications, register listener
   // and activate MOVE SDK features.
   moveSdk.apply {
     recognitionNotification(recognitionNotification)
     tripNotification(drivingNotification)
     sdkStateListener(sdkStateListener)
     tripStateListener(tripStateListener)
     authStateUpdateListener(authStateListener)
     initializationListener(initListener)
     initiateAssistanceCall(assistanceListener)
     consoleLogging(true)
   }
   
   ...
   
   // Configuration of the MOVE SDK
   val moveServices: MutableSet<MoveDetectionService> = mutableSetOf()
   
   val drivingServices: MutableSet<DrivingService> = mutableSetOf()
   drivingServices.add(DrivingService.DrivingBehaviour)
   drivingServices.add(DrivingService.DistractionFreeDriving)
   drivingServices.add(DrivingService.DeviceDiscovery)

   val walkingServices: MutableSet<WalkingService> = mutableSetOf()
   walkingServices.add(WalkingService.Location)

   moveServices.add(MoveDetectionService.Driving(drivingServices = drivingServices.toList()))
   moveServices.add(MoveDetectionService.Walking(walkingServices = walkingServices.toList()))
   moveServices.add(MoveDetectionService.Cycling)
   moveServices.add(MoveDetectionService.AutomaticImpactDetection)
   moveServices.add(MoveDetectionService.AssistanceCall)
   
   val moveConfig = MoveConfig(moveDetectionServices = moveServices.toList())
   
   ...
   
   MoveAuth(
            projectId =  projectId ?: 0L,
            userId = userId ?: "",
            accessToken = accessToken ?: "",
            refreshToken = refreshToken ?: ""
        )
   
   ...
   
   moveSdk.setup(
           auth = auth,
           config = moveConfig,
           start = false
   )   
   
}

You need to replace projectId, userId, accessToken, and refreshToken with your own values.

Last updated