Creating dynamic always-on wearable apps
An always-on app provides the user with the ability to view information at any time, without having to wake the device; however, the visible information may become stale if the actual information changes more frequently than once in a minute.
How to do it...
We may need to update the content on the wearable more frequently than once in a minute; thus, we can schedule an alarm to trigger an update outside the one-minute interval:
- We will need the wake lock permission on both, the handheld and wearable:
[assembly: UsesPermission(Manifest.Permission.WakeLock)]
- If we want to support older wearables, we will need to set the wearable library as optional:
[assembly: UsesLibrary( "com.google.android.wearable", false)]
- Next, we need to inherit it from
WearableActivity
:public class MainActivity : WearableActivity
- We are going to use the alarm manager to send us an
Intent
instance, which we will respond to by updating the UI. As the intent will try to launch...