Skip to content

DriveMotionMonitorClient

DriveMotionMonitorClient mainly provides some monitor functions for trip upload status. developers must obtain DriveMotionMonitorClient after initializing DriveMotion.

Get DriveMotionMonitorClient

1
2
3
4
5
    try {
        DriveMotionMonitorClient driveMotionMonitorClient = DriveMotionService.getDriveMotionMonitorClient();
    } catch (DriveMotionException e) {
        // The SDK is not initialized
    }
1
2
3
4
5
    try {
        val driveMotionMonitorClient: DriveMotionMonitorClient = DriveMotionService.getDriveMotionMonitorClient()
    } catch (e: DriveMotionException) {
        // The SDK is not initialized
    }

Use DriveMotionMonitorClient

DriveMotionMonitorClient provides some monitor functions for trip upload status.

Get Upload Progress Request

the GetUploadProgressRequest will get the trip upload progress.

Build Request

1
    GetUploadProgressRequest request = driveMotionMonitorClient.getUploadProgressRequest().build();
1
    val request = driveMotionMonitorClient.getUploadProgressRequest().build()

Create a Call and execute it

Callback is a closure accepting response and error parameters.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    Callback<GetUploadProgressResponse> callback = new Callback<GetUploadProgressResponse>() {

        @Override
        public void onSuccess(GetUploadProgressResponse uploadProgressResponse) {
            // Do something
        }

        @Override
        public void onFailure(Throwable throwable) {
            // Do something
        }
    }
1
2
3
4
5
6
7
8
9
    val callback = object : Callback<GetUploadProgressResponse> {
        override fun onSuccess(uploadProgressResponse: GetUploadProgressResponse) {
            // Do something
        }

        override fun onFailure(throwable: Throwable) {
            // Do something
        }
    }

Get Upload Success Timestamp

the GetUploadSuccessTimestampRequest will get trip upload success timestamp.

Build Request

1
    GetUploadSuccessTimestampRequest request = driveMotionMonitorClient.getUploadSuccessTimestampRequest().build();
1
    val request = driveMotionMonitorClient.getUploadSuccessTimestampRequest().build()

Create a Call and execute it

Callback is a closure accepting response and error parameters.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    Callback<GetUploadSuccessTimestampResponse> callback = new Callback<GetUploadSuccessTimestampResponse>() {

        @Override
        public void onSuccess(GetUploadSuccessTimestampResponse uploadSuccessTimestampResponse) {
            // Do something
        }

        @Override
        public void onFailure(Throwable throwable) {
            // Do something
        }
    }
1
2
3
4
5
6
7
8
9
    val callback = object : Callback<GetUploadSuccessTimestampResponse> {
        override fun onSuccess(uploadSuccessTimestampResponse: GetUploadSuccessTimestampResponse) {
            // Do something
        }

        override fun onFailure(throwable: Throwable) {
            // Do something
        }
    }

Bluetooth unavailable during trip (since 3.18.0)

With edge matching enabled, the SDK can notify the app if phone Bluetooth is off, app permission is not granted, or both, after a configurable delay from trip start, while a trip is already in progress. The trip is not ended; this is for in-trip diagnostics and analytics.

On Android, this is delivered through your subclass of DriveMotionMonitorReceiver (registered in DriveMotionSettings for the monitor component). Override:

1
2
3
4
@Override
public void onBluetoothUnavailableDuringTrip(BTUnavailableEvent event) {
    // event.getTripId(), event.getCause() — BTUnavailableCauseType: APP_PERMISSION_OFF, PHONE_BT_OFF, BOTH, UNINITIALIZED
}
1
2
3
override fun onBluetoothUnavailableDuringTrip(event: BTUnavailableEvent) {
    // event.tripId, event.cause
}

BroadcastActions.ACTION_MONITOR_BT_UNAVAILABLE_DURING_TRIP is used internally for this broadcast when the monitor receiver is configured.

Threshold configuration

Set btUnavailableTripThresholdSec on the resolved DriveMotionConfig (JSON key btUnavailableTripThresholdSec from remote DriveMotion config). The default is 120 seconds when not specified.