What is the Awareness API?

With the Google Awareness API, you can enable your app to intelligently react to the user's current situation. The Awareness API exposes 7 different types of context, including location, weather, user activity, and nearby beacons, enabling 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 (for example, suggesting a playlist when the user plugs in headphones and starts jogging).

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 your app doesn't have to.

Fences and snapshots

The Awareness API consists of two distinct APIs which your app can use to get context signals to determine the user's current situation:

  • Fence API lets your app react to the user's current situation, and provides notification when a combination of context conditions are met. For example, "tell me whenever the user is walking 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 lets your app request information about the user's current context. For example, "give me the user's current location and the current weather conditions".

Context types

Context is at the heart of the Awareness API. Contextual data includes sensor-derived data such as location (lat/lng), place type (park, coffee shop), and activity (walking, driving). These basic signals can be combined to extrapolate the user's situation in more specific detail.

The following table describes the basic context types currently offered by the Awareness API:

Context type Example
Time Current local time
Location Latitude and longitude
Place (Deprecated) Place, including place type
Activity Detected user activity (walking, running, biking)
Beacons Nearby beacons matching the specified namespace
Headphones Are headphones plugged in?
Weather (Deprecated) Current weather conditions