Best practices for the Awareness API
Stay organized with collections
Save and categorize content based on your preferences.
The Awareness API gives you the power to react to changes in a user's context,
but with this great power comes great responsibility. In order to provide an
optimal experience for your users, consider the following guidelines.
- Be mindful of user expectations
- Be sure the user understands what to expect from your app. For example, suppose
your app is designed to instantly play music when the user plugs in their
headphones. This could result in a bad experience if the user doesn't expect
such behavior.
- Be conservative with notifications
- If your app sends notifications, clearly communicate this to the user.
Send only notifications that are relevant to the user. Keep in mind that your
app must coexist with many other apps that might also send notifications.
- Conserve system health
- Although great effort was spent to make the Awareness API efficient,
it still has the potential to consume significant amounts of battery life if
used carelessly. The Awareness API manages system health for you. However, if you
register too many fences, the Awareness API throttles callbacks to prevent
undue battery drain. Likewise, excessive snapshot requests can also
drain battery life.
- Use the Awareness API for awareness
- If your app needs to perform tasks that aren't time-sensitive, such as data
synchronization or cleanup operations, consider the
JobScheduler API
to perform such tasks.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe Awareness API lets your app react to user context changes, but it's crucial to use it responsibly to avoid negative user experiences.\u003c/p\u003e\n"],["\u003cp\u003eManage user expectations by clearly indicating how your app will utilize the Awareness API and what actions it might trigger.\u003c/p\u003e\n"],["\u003cp\u003eMinimize notifications and ensure they are relevant to the user to prevent notification overload and maintain a positive user experience.\u003c/p\u003e\n"],["\u003cp\u003eBe aware of the Awareness API's potential impact on battery life and avoid excessive fence registrations or snapshot requests.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the Awareness API primarily for context-aware features and consider alternatives like JobScheduler for non-time-sensitive tasks.\u003c/p\u003e\n"]]],[],null,["# Best practices for the Awareness API\n\nThe Awareness API gives you the power to react to changes in a user's context,\nbut with this great power comes great responsibility. In order to provide an\noptimal experience for your users, consider the following guidelines.\n\nBe mindful of user expectations\n: Be sure the user understands what to expect from your app. For example, suppose\n your app is designed to instantly play music when the user plugs in their\n headphones. This could result in a bad experience if the user doesn't expect\n such behavior.\n\nBe conservative with notifications\n: If your app sends notifications, clearly communicate this to the user.\n Send only notifications that are relevant to the user. Keep in mind that your\n app must coexist with many other apps that might also send notifications.\n\nConserve system health\n: Although great effort was spent to make the Awareness API efficient,\n it still has the potential to consume significant amounts of battery life if\n used carelessly. The Awareness API manages system health for you. However, if you\n register too many fences, the Awareness API throttles callbacks to prevent\n undue battery drain. Likewise, excessive snapshot requests can also\n drain battery life.\n\nUse the Awareness API for awareness\n: If your app needs to perform tasks that aren't time-sensitive, such as data\n synchronization or cleanup operations, consider the\n [JobScheduler API](http://developer.android.com/reference/android/app/job/JobScheduler)\n to perform such tasks."]]