With the Google Awareness API, you can enable your app to intelligently react to the user's current situation. The Awareness API exposes five different context types, which include user activity, and nearby beacons. These types enable your app to refine the user experience in new ways that weren't possible before. Your app can combine these context signals to make inferences about the user's current situation, and use this information to provide customized experiences, such as a playlist suggestion when the user plugs in their headphones and starts to jog.
Awareness API benefits
The Awareness API provides several benefits:
- Ease of implementation: You only need to add a single API to your app, which greatly simplifies integration and improves your productivity.
- Better context data: Raw signals are processed for improved quality. For example, advanced algorithms are used to determine the user's activity with a high level of accuracy.
- Optimal system health: The Awareness API automatically manages its impact on battery life and data usage so that your app doesn't have to.
Fences and snapshots
The Awareness API consists of two distinct APIs that your app can use to get context signals in order to determine the user's current situation:
- Fence API: This API lets your app react to the user's current situation, and provides notification when a combination of context conditions are met. For example, whenever the user takes a walk and their headphones are plugged in. Once a fence is registered, the Fence API can send callbacks to your app even when it's not running.
- Snapshot API: This API lets your app request information about the user's current context, such as the user's current location and the current weather conditions.
Context is at the heart of the Awareness API. Contextual data includes sensor-derived data such as location (latitude and longitude), place type, like a park or coffee shop, and activity, such as a walk or drive. These basic types, or signals, can be combined to extrapolate the user's situation in more specific detail. Expand the following notice to see which contextual signals have been deprecated.
The following table describes the basic context types currently offered by the Awareness API:
|Current local time
|Latitude and longitude
|Detected user activity, like walking, running, or biking
|Nearby beacons that match the specified namespace
|Status of whether headphones are plugged in, or not