New feature - tracking our steps
Everyone loves step counters. How about we build one for our wearable device? Not much to talk about here, so let's dive into the code.
Add to-do item - a new action in the wearable app
The first thing we will do here is to add a menu item
to the wearable app. Let's call it Step Count
. Our changes to arrays.xml
file would be as follows:
<?xml version="1.0" encoding="utf-8"?> <resources> <string-array name="actions"> <item>Day of Year</item> <item>On this day...</item> <item>Add Todo Item</item> <item>Step Count</item> </string-array> </resources>
This action should now show up on the wearable app, as shown in the following figure:
Click on the Step Count
menu item to launch the corresponding StepCounterActivity
activity. The code for that class is given here. Note how the activity implements the SensorEventListener
class. We hook up...