Runtastic on Android Wear
By Austin
Robison, Product Manager, Android Wear
Fitness apps make great
additions to Android Wear. Let’s take a look at one of our favorites, Runtastic. Runtastic is a fitness app that lets you track your walks, runs, bike rides
and more. With Runtastic on Android Wear, you'll see your time, distance, and calories burned
at a glance on your wrist. You can also start, stop and pause your activity by touch. Tuck
your phone away in a pocket or backpack and do everything on your
watch.
It's challenging to build user
experiences that really come alive on Android Wear because it's such a new type of device.
Runtastic does a great job of showing the right information and providing just the right
controls on the screen on your wrist. Let's dig into some of the Android Wear platform
features that Runtastic uses to make such a great user experience.
Voice
Actions
Android Wear enables developers to launch
their activities with voice. Runtastic responds to “Ok Google, start running” by beginning to
track a session and displaying a card with your total time. This means you can start
exercising without needing to pull your phone out of a pocket or arm strap. Android Wear is
all about bringing you useful information just when you need it and enabling users to quickly and easily
take action.
Responding to platform voice intents on
Wear is as simple as declaring a standard intent filter to start an activity. For
example, to launch your activity for the “start running” voice action, add the following to
your activity’s entry in your AndroidManifest.xml:
<intent-filter>
<action
android:name="vnd.google.fitness.TRACK"/>
<category
android:name="android.intent.category.DEFAULT"/>
<data
android:mimeType="vnd.google.fitness.activity/running"/>
</intent-filter>
Custom
Cards
Once a user has started a run, Runtastic
inserts a card in the stream as an ongoing notification to ensure it is ranked near the top of
the stream during the activity. This card uses the setDisplayIntent() function to display custom UI. It provides quick, glanceable
information, showing your activity time. Cool!
When the user swipes to the right of the
card to expose its actions, we see some quick and easy to understand options; following the
Android Wear style guidelines means that Runtastic has a familiar UI
and feels like a natural extension of the watch. There are actions for pausing, stopping, and
an action to see more details on the run. This action launches a full screen
Activity where Runtastic draws a completely custom layout.
You’ll notice this data updates live;
Runtastic makes use of the Wearable Data Layer API in Google Play Services to synchronize data between the phone and
the watch. It's an easy to use API for syncing data between your
devices.
Background
Services
When a user finishes their run, Runtastic
presents them with a special summary card that appears only on the watch. In this case, the
notification is generated directly on the watch by a Service. This Service uses the Data Layer
to receive information about the completed activity from the phone to the watch, including an
image of a map of the user’s run generated through the Google Maps
API.
To show that information, the app uses
Android Wear’s NotificationManager, which functions just like the NotificationManager on a
phone or tablet, except that instead of creating notifications in the pull-down shade, they
appear in the stream.
Runtastic's implementation on Android
Wear is a perfect example of how to take advantage of wearables to make something truly useful
for users. For more information on these and other great platform features, please see the
developer documentation.
For more inspiring Android Wear user
experiences, check out this collection on the Play Store!
Posted by
Mano Marks, Google
Developer Platform Team