GooglePlayServicesObserver

Observer for Google Play Services related events.

Use this interface to track SDK interactions with Google Play Services location APIs, such as requesting and removing location updates.

GooglePlayServicesObserver API

onRequestLocationUpdates

void onRequestLocationUpdates(LocationRequest request, Task<Void> result)

Called when the SDK requests location updates from Google Play Services. The SDK uses a single PendingIntent for all location update requests. Multiple requests may use different LocationRequest parameters, but all share the same PendingIntent. Removing location updates therefore clears all active requests. Use result to inspect whether the request succeeded or failed.

onRemoveLocationUpdates

void onRemoveLocationUpdates(Task<Void> result)

Called when the SDK removes location updates from Google Play Services. Because all requests share a single PendingIntent, removing updates clears all active requests. Use result to inspect whether the remove request succeeded or failed.

Threading

Observer callbacks are posted on the main thread.

Example

GooglePlayServicesObserver observer = new GooglePlayServicesObserver() {
    @Override
    public void onRequestLocationUpdates(LocationRequest request, Task<Void> result) {
        // Inspect request and async result.
    }

    @Override
    public void onRemoveLocationUpdates(Task<Void> result) {
        // Inspect async remove result.
    }
};

SdkDiagnostics diagnostics =
        new SdkDiagnostics.Builder()
                .googlePlayServicesObserver(observer)
                .build();

SentianceOptions options =
        new SentianceOptions.Builder(context)
                .diagnostics(diagnostics)
                .build();

Last updated