AI-generated Key Takeaways
-
SnapshotClient is the main entry point for the Awareness Snapshot API.
-
It provides methods to get the current information about nearby beacons, the user's current activity, whether headphones are plugged in, the device's current location, and semantic time intervals.
-
Some methods require specific permissions declared in AndroidManifest.xml and user consent at runtime.
-
Beacon snapshots are only available on devices running API level 18 or higher.
Main entry point for the Awareness Snapshot API.
See Also
Inherited Field Summary
Public Method Summary
| Task < BeaconStateResponse > | getBeaconState
( Collection
< BeaconState.TypeFilter
>
beaconTypes)
Gets the current information about nearby beacons.
|
| Task < BeaconStateResponse > | |
| Task < DetectedActivityResponse > | getDetectedActivity
()
Gets the user's current activity (e.g., running, walking, biking, driving,
etc.).
|
| Task < HeadphoneStateResponse > | |
| Task < LocationResponse > | |
| Task< TimeIntervalsResponse > |
Inherited Method Summary
Public Methods
public Task < BeaconStateResponse > getBeaconState ( Collection < BeaconState.TypeFilter > beaconTypes)
Gets the current information about nearby beacons. Note that beacon snapshots are
only available on devices running API level 18 or higher. If calling from a device
running API level 17 or earlier, the Task
will fail
and calling getStatusCode()
will return status code API_NOT_AVAILABLE
.
To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION
permission in AndroidManifest.xml,
and the user must provide consent at runtime.
Parameters
Returns
- a
TaskwithBeaconStateResponse. UseisSuccessful()to determine success or failure. If successful, usegetBeaconState()to get data on the nearby beacons.
Throws
public Task < BeaconStateResponse > getBeaconState ( TypeFilter... beaconTypes)
Gets the current information about nearby beacons. Note that beacon snapshots are
only available on API level 18 or higher. If calling from a device prior to API level
18, the Task
will fail
and calling getStatusCode()
will return status code API_NOT_AVAILABLE
.
To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION
permission in AndroidManifest.xml,
and the user must provide consent at runtime.
Parameters
Returns
- a
TaskwithBeaconStateResponse. UseisSuccessful()to determine success or failure. If successful, usegetBeaconState()to get data on the nearby beacons.
Throws
public Task < DetectedActivityResponse > getDetectedActivity ()
Gets the user's current activity (e.g., running, walking, biking, driving, etc.).
To call this function, a different permission is required depending on your Android API level:
- For Android 10 (API level 29) and later: android.permission.ACTIVITY_RECOGNITION permission
- For Android 9 (API level 28) and earlier: com.google.android.gms.permission.ACTIVITY_RECOGNITION permission
Returns
- a
TaskwithDetectedActivityResponse. UseisSuccessful()to determine success or failure. If successful, then usegetActivityRecognitionResult()to get the current activity.
Throws
public Task < HeadphoneStateResponse > getHeadphoneState ()
Reports whether headphones are plugged into the device.
Returns
- a
TaskwithHeadphoneStateResponse. UseisSuccessful()to determine success or failure. If successful, usegetHeadphoneState()to get the current headphone state.
public Task < LocationResponse > getLocation ()
Gets the device's current location (lat/lng).
To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION
permission in AndroidManifest.xml
, and the user must provide consent at runtime.
Returns
- a
TaskwithLocationResponse. UseisSuccessful()to determine success or failure. If successful, then usegetLocation()to get the current device location.
Throws
public Task < TimeIntervalsResponse > getTimeIntervals ()
Gets the semantic time intervals for the to the current time and location. As
examples, some attributes are: TIME_INTERVAL_MORNING
, TIME_INTERVAL_AFTERNOON
, TIME_INTERVAL_EVENING
, TIME_INTERVAL_NIGHT
, TIME_INTERVAL_WEEKDAY
, TIME_INTERVAL_WEEKEND
, TIME_INTERVAL_HOLIDAY
.
To use this method, your app must declare the android.permission.ACCESS_FINE_LOCATION
permission in AndroidManifest.xml,
and the user must provide consent at runtime.
Returns
- a
TaskwithTimeIntervalsResponse. UseisSuccessful()to determine success or failure. If successful, then usegetTimeIntervals()to get the attributes of the current day and time.

