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.