Skip to content

DriveMotionUsersClient

DriveMotion supports switching user opt in status through method calls optInRequest or optOutRequest when DriveMotionSettings.withOptInRequired(isOptInRequired) is set to true. To use this feature, developers must obtain DriveMotionUsersClient after initializing DriveMotion.

Get DriveMotionUsersClient

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

Use DriveMotionUsersClient

DriveMotionUsersClient provides the entrance to get user profiles, opt in, opt out, and delete user account.

Get User Profile Request

The getUserProfileRequest method will retrieve and update current user profile from cloud service if any of userAlias, userState, or userConsent is changed.

Build Request

1
    GetUserProfileRequest request = driveMotionUsersClient.getUserProfileRequest().build();
1
    val request = driveMotionUsersClient.getUserProfileRequest().build()

Implement Callback

Callback is an interface, and developers need to specify its response type. It provides two callback entries for success and failure.

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

        @Override
        public void onSuccess(GetUserProfileResponse userProfileResponse) {
            // Do something
        }

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

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

Opt In Request

The optInRequest method will let user opt in when isOptInRequired is true.

Build Request

1
    OptInRequest request = driveMotionUsersClient.optInRequest().build();
1
    val request = driveMotionUsersClient.optInRequest().build()

Implement Callback

Callback is an interface, and developers need to specify its response type. It provides two callback entries for success and failure.

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

        @Override
        public void onSuccess(OptInResponse optInResponse) {
            // Do something
        }

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

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

Opt Out Request

The optOutRequest method will let user opt out when isOptInRequired is true.

Build Request

1
    OptOutRequest request = driveMotionUsersClient.optOutRequest().build();
1
    val request = driveMotionUsersClient.optOutRequest().build()

Implement Callback

Callback is an interface, and developers need to specify its response type. It provides two callback entries for success and failure.

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

        @Override
        public void onSuccess(OptOutResponse optOutResponse) {
            // Do something
        }

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

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

Delete Account And Data Request

The deleteAccountAndDataRequest method will delete user account and trip data.

Build Request

1
    DeleteAccountAndDataRequest request = driveMotionUsersClient.deleteAccountAndDataRequest().build();
1
    val request = driveMotionUsersClient.deleteAccountAndDataRequest().build()

Implement Callback

Callback is an interface, and developers need to specify its response type. It provides two callback entries for success and failure.

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

        @Override
        public void onSuccess(DeleteAccountAndDataResponse deleteAccountAndDataResponse) {
            // Do something
        }

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

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