Watchface Wearable Settings


It is often better to give the user the possibility to change some settings and to personalize the app. There are two approaches for a wearable app to provide a configuration screen. You can add a configuration screen to your wearable app or you can add one to the mobile app, so the user can change settings from the companion app. Because of the relative small display of a smartwatch, you should limit the settings and ideally only give binary choices. The handheld app can allow complex configurations, like a color dialog.

Configuration Intent

To expand a watchface service to a configuration, we need to open the wearable manifest file and add the following code to the service tag:

 android:value="com.infectedbytes.example.watchface.samplewatch.CONFIG_DIGITAL" />

The value of android:value attribute should match your package name. The activity must also use this value.

The configuration activity, registers an Intent filter, such that the system starts the activity when an user taps the gear icon.

Wearable Activity

To keep this tutorial as easy as possible, we will only create a new "Blank Activity". Afterwards we change the view from mobile to wearable. Just change the layout from Nexus 4 to a wearable (Square or Round).

Now you should design a simple UI. For sake of simplicity we will skip this step and just use the blank activity.

Now we look again to the wearable app manifest. An activity entry was added automatically. We now have to add an Intent filter to this activity. This will define to which events our activity will respond.

    <action android:name="com.infectedbytes.example.watchface.samplewatch.CONFIG_DIGITAL" />
    <category android:name="" />
    <category android:name="android.intent.category.DEFAULT" />

The value of <action android:name="..."> must match the value from the previous meta tag.

Now, if all went well, you can recompile and run it. In the watchface selection screen, you will now get a small gear icon under your watchface. When you tap it, the blank activity is started.

And so we are the end of the tutorial. On the next page you will find again the code of the manifest for comparison.