Creating always-on wearable apps
The ability to create fully-featured apps for Android wearables is a great way to provide a hands-free experience. However, to preserve battery, Android will quickly put the device to sleep, resulting in the experience being lost.
How to do it...
Sometimes, we want to be able to display content on the screen, even when the wearable goes to sleep or enters the ambient mode:
- The first thing that we need to do is add the wake lock permission requirement. We need to add this to both, wearable and handheld, as the wearable cannot have any permission that the handheld does not have:
[assembly: UsesPermission(Manifest.Permission.WakeLock)]
- Next, in the wearable app, we need to specify that we are going to be using the wearable library if it is available:
[assembly: UsesLibrary( "com.google.android.wearable", false)]
- Now, we can begin implementing the always-on activity. Instead of inheriting from
Activity
, we can inherit fromWearableActivity
:public class...