**Deprecation notice: Awareness API is deprecated.**

> [!WARNING]
> **Warning:** The Awareness API is deprecated.
>
> - Google Play services will stop supporting the Awareness API in a future release, as early as January 2027.
> - There is no direct replacement.

You can use the [Snapshot API](https://developers.google.com/android/reference/com/google/android/gms/awareness/Awareness.md.txt#getSnapshotClient(android.app.Activity))
to get information about the user's current environment. With the Snapshot API,
you can access a variety of [context signals](https://developers.google.com/awareness/overview.md.txt#context-types):

- Detected user activity, such as when they walk or drive.
- Nearby beacons that you've registered.
- Headphone state, plugged in or not.
- Location, which includes latitude and longitude.

The system caches these values so that they can be returned quickly. If there's
no data, sensing and inference are performed to return fresh state values.
The Awareness API returns the existing data type for context types that have a
public API.

Each context signal has a corresponding Snapshot API method. For example, to
get the current detected activity, you call
[`getDetectedActivity()`](https://developers.google.com/android/reference/com/google/android/gms/awareness/SnapshotClient.md.txt#getDetectedActivity()),
use a `SuccessListener` to get a [`DetectedActivityResponse`](https://developers.google.com/android/reference/com/google/android/gms/awareness/snapshot/DetectedActivityResponse.md.txt),
then call [`getActivityRecognitionResult()`](https://developers.google.com/android/reference/com/google/android/gms/awareness/snapshot/DetectedActivityResponse.md.txt#getActivityRecognitionResult())
to return an [`ActivityRecognitionResult`](https://developers.google.com/android/reference/com/google/android/gms/location/ActivityRecognitionResult.md.txt)
from which you can get the actual request data.

The following example shows how to get the latest detected activity:

            Awareness.getSnapshotClient(this).getDetectedActivity()
                .addOnSuccessListener(new OnSuccessListener<DetectedActivityResponse>() {
                    @Override
                    public void onSuccess(DetectedActivityResponse dar) {
                        ActivityRecognitionResult arr = dar.getActivityRecognitionResult();
                    }
                })

For more information about what you can do with the request data, see
[Get Snapshot data](https://developers.google.com/awareness/android-api/snapshot-get-data.md.txt).