Dolphin MOVE SDK
2.x
2.x
  • Introduction
  • MOVE Services
  • MOVE SDK
    • Getting Started
      • MOVE Dashboard
        • Access Control
        • Configuration
        • Timeline
        • Points of Interest
      • Android
        • Installation
        • Quick Start
      • iOS
        • Installation
        • Quick Start
        • Troubleshooting
      • React Native
      • Flutter
      • Move SDK CLI
    • API Interface
      • Android
        • Initialization
        • Services
      • iOS
        • Initialization
        • Setup
        • Services
      • React Native
        • Components
        • Initialization
        • Services
      • Flutter
        • Initialization
        • Services
    • Models
      • Listeners/Callbacks
      • MoveAssistanceCallStatus
      • MoveAuth
      • MoveAuthError
      • MoveAuthResult
      • MoveAuthState
      • MoveConfig
      • MoveConfigurationError
      • MoveDevice
      • MoveDeviceStatus
      • MoveGeocodeError
      • MoveHealthItem
      • MoveHealthScore
      • MoveOptions
        • DeviceDiscovery
      • MoveSdkState
      • MoveSdkAndroidConfig
      • MoveTripState
      • MoveScanResult
      • MoveServiceFailure
      • MoveServiceWarning
      • MoveShutdownResult
    • Appendix
      • Token refresh
      • Android
        • Permission Handling
          • Permission Overview
          • Runtime Permissions
        • Battery optimization
        • Notification Management
      • iOS
        • Permissions Handling
        • App Store
      • React Native
        • Permission Handling
  • MOVE Backend
    • MOVE Backend
      • MOVE Admin API
      • MOVE TIMELINE API
      • MOVE State API
      • MOVE Last Location API
    • MOVE Generic Notifier
    • MOVE Assistance Notifier
    • Example requests
  • FAQ
  • Changelog
    • Android
    • iOS
    • React
    • Flutter
    • Backend
  • Data privacy (GDPR)
Powered by GitBook
On this page
  • Init
  • Config
  • Setup
  • With MoveAuth
  • With authCode
  • Listeners
  • Initialization listener
  • Auth state update listener
  • MOVE SDK State listener
  • Trip state listener
  • Trip notifications
  • Walking notifications
  • Recognition notifications
  • Trip Metadata
  • Initialization
  1. MOVE SDK
  2. API Interface
  3. Android

Initialization

API Interface / Android

Init

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.

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(...).

// 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)
     setServiceErrorListener(errorListener)
     setServiceWarningListener(warningListener)
     initiateAssistanceCall(assistanceListener)
     deviceDiscoveryListener(deviceDiscoveryListener)
     consoleLogging(true)
   }
   
   // ... continue with Config ...
}

By clicking the links below you can find further information about the usage.

Config

Whenever you are ready to start the Move SDK, setup() needs to be called with a proper configuration. The following code sample demonstrates a common configuration with driving, walking, cycling, automatic impact detection and assistance call.

   // ... Init ...
   
   // Example of a 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())
   
   // ... continue with Setup ...

Setup

It is recommended to set up notifications before calling the setup() method.

It is recommended that .setup(...) is called ONLY ONCE!

If .shutdown() was called before then .setup(...) must be redone.

With MoveAuth

.setup(
    auth: MoveAuth, 
    config: MoveConfig,
    start: Boolean?,
    options: MoveOptions?
)

auth

config

The move configuration

start

Boolean

options

optional: added with v2.3.+

SDK Authentication

With authCode

.setup(
    authCode: String, 
    config: MoveConfig,
    start: Boolean?,
    options: MoveOptions?,
    callback: MoveAuthCallback
)

authCode

String

config

The move configuration

start

Boolean

options

callback

MoveAuthCallback

Example of implementing the MoveAuthCallback:

private val moveAuthCallback = object : MoveSdk.MoveAuthCallback {
    override fun onResult(result: MoveAuthResult) {
        when (result.status) {
            AuthSetupStatus.SUCCESS -> {
                // Do something if the result is SUCCESS.
            }
            AuthSetupStatus.INVALID_CODE -> {
                // Do something if the result is INVALID_CODE.
            }
            AuthSetupStatus.NETWORK_ERROR -> {
                // Do something if the result is NETWORK_ERROR.
            }
        }
    }
}

Listeners

Initialization listener

.initializationListener(listener: MoveInitializeListener)

Parameter

Description

listener

Block that gets invoked on initialization completion with error. On error,

Auth state update listener

.authStateUpdateListener(callback: AuthStateUpdateListener)

Callback

AuthStateUpdateListener

Authentication Expiry

MOVE SDK State listener

.sdkStateListener(listener: MoveSdkStateListener)

Parameter

Description

listener

Trip state listener

.tripStateListener(listener: MoveTripStateListener)

Parameter

Description

listener

Trip notifications

.tripNotification(notification: Notification.Builder)

Parameter

Description

notification

The notification builder to build the notification

Walking notifications

.walkingNotification(notification: Notification.Builder)

Parameter

Description

notification

The notification builder to build the notification

Recognition notifications

.recognitionNotification(notification: Notification.Builder)

Parameter

Description

notification

The notification builder to build the notification

Trip Metadata

Host apps can use this API to add any app-level information (for ex. bluetooth beacon detected, foreground/background time, etc) to append to a trip as metadata. This metadata will be forwarded back along with the trip when fetched by the client-server, so the host app can utilize it in its app. Note: The MOVE SDK will not use this metadata element in any way, it is just passed through to the project.

The block provides the trip's start and stop times. Make sure to only include metadata events that are collected inside the given start and end periods.

.metadataProvider(provider: TripMetadataProvider)

Parameter

Description

Callback to provide a bundle of key-value pairs to a trip. The trip is represented with a given start and stop time.

Initialization

Application Context

Make sure to pass the application context

Parameter

Description

context

Main application context.

fun init(context: Context): MoveSdk

Return

MoveSdk

The instance of the MoveSdk

Throws

MissingAuthenticationException

If the passed configuration is missing, e.g. empty access token

PreviousAndroidNextServices

Last updated 9 months ago

Used Services in the example above and :

Deprecated in the future. The new approach is by using an authCode. see

The data for the MoveAuth object must be fetched using the given project’s API Key (see ).

The user's Auth object. (see )

optional: Default: true -> is called automatically false -> you have to call manually

Passing the authentication config is required for each setup. The host app is also responsible for monitoring the changes.

If you want to use startTrip(...) () you have to pass false to the parameter start.

The authCode must be fetched using the userId (see ).

The authCode received from the backend. (see )

optional: Default: true -> is called automatically false -> you have to call manually

This listener will report the success or failure during the internal MOVE SDK authentication process. (see )

Block that gets invoked on initialization completion with error. On error, is returned. On success, the will change accordingly.

is returned.

Provide a block to be invoked every time changes.

Block that gets invoked every time is updated.

The host app is expected to monitor updates viaauthStateUpdateListenerAPI and handle those changes accordingly.

Check for more details about authentication expiry and renewal.

Provide a block to be invoked every time changes.

The host app is expected to be monitoring changes so it can start the SDK services when is.readyor handle errors if occurred.

Block gets called whenever the changes.

A listener where gets called whenever the changes

Passes a notification builder which is used to create a notification reaching places and walking paths. For more information on that please check.

Passes a notification builder which is used to create a notification for places and walking paths. For more information on that please check.

Passes a notification builder which is used to create notification while detecting activities, trips and more. For more information on that, please check.

Tries to initialize the MOVE SDK. You can only have one initialized MOVE SDK at a time. If you have a MOVE SDK instance already, consider calling before. The initialization process is asynchronous and the host app is expected to register a to monitor successful initialization and start services when transits toREADY . The host app should also monitor to handle potential .

If you have already successfull initialized the MOVE SDK once, try to initialize the MOVE SDK next time in your application in . This ensures that the MOVE SDK can do its work whenever the application is restarted after termination.

more
AuthState
MoveAuthState
MoveAuthState
MoveSdkState
MoveSdkState
MoveSdkState
notification management
notification management
notification management
onCreate
recognitionNotification
tripNotification
sdkStateListener
tripStateListener
authStateUpdateListener
initializationListener
Setup with authCode
MoveAuth
MoveConfig
MoveOptions
MoveConfig
MoveOptions
MoveAuthResult
MoveConfigurationError
MoveAuthState
MoveSdkState
MoveTripState
onTripStateChanged
MoveSdkState
MoveSDKState
MoveSdkState
MoveConfigurationError
listener
initialization listener
Authentication updates and expiry
MoveConfigurationError
MOVE Backend - Example request
MOVE Backend - Example request
MOVE Backend - Create a new user
MOVE Backend - Create a new user
InitializeListener
MoveSdkStateListener
MoveTripStateListener
provider
setServiceErrorListener
setServiceWarningListener
initiateAssistanceCall
consoleLogging
deviceDiscoveryListener
Manual Start Trip
shutdown
startAutomaticDetection()
startAutomaticDetection()
startAutomaticDetection()
startAutomaticDetection()