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(...).
By clicking the links below you can find further information about the usage.
Used Services in the example above and more:
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.
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
Deprecated in the future. The new approach is by using an authCode. see Setup with authCode
The data for the MoveAuth object must be fetched using the given project’s API Key (see MOVE Backend - Example request).
SDK Authentication
Passing the authentication config is required for each setup. The host app is also responsible for monitoring the AuthState changes.
If you want to use startTrip(...) (Manual Start Trip) you have to pass false to the parameter start.
With authCode
The authCode must be fetched using the userId (see MOVE Backend - Example request).
Example of implementing the MoveAuthCallback:
Listeners
Initialization listener
Block that gets invoked on initialization completion with error. On error, MoveConfigurationError is returned. On success, the MoveSdkState will change accordingly.
Auth state update listener
Provide a block to be invoked every time MoveAuthState changes.
Authentication Expiry
The host app is expected to monitor MoveAuthState updates viaauthStateUpdateListener
API and handle those changes accordingly.
Check Authentication updates and expiry for more details about authentication expiry and renewal.
MOVE SDK State listener
Provide a block to be invoked every time MoveSdkState changes.
The host app is expected to be monitoring MoveSdkState changes so it can start the SDK services when MoveSdkState is.ready
or handle errors if occurred.
Trip state listener
Trip notifications
Passes a notification builder which is used to create a notification reaching places and walking paths. For more information on that please check notification management.
Walking notifications
Passes a notification builder which is used to create a notification for places and walking paths. For more information on that please check notification management.
Recognition notifications
Passes a notification builder which is used to create notification while detecting activities, trips and more. For more information on that, please check notification management.
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.
Initialization
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 shutdown
before.
The initialization process is asynchronous and the host app is expected to register a MoveSDKState listener
to monitor successful initialization and start services when MoveSdkState transits toREADY
. The host app should also monitor initialization listener
to handle potential MoveConfigurationError.
If you have already successfull initialized the MOVE SDK once, try to initialize the MOVE SDK next time in your application in onCreate. This ensures that the MOVE SDK can do its work whenever the application is restarted after termination.
Last updated