# 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`

> ```java
> 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`

> ```java
> 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

```java
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();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sentiance.com/important-topics/sdk/api-reference/android/sdkdiagnostics/googleplayservicesobserver.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
