Watchface Handheld Settings

Category: 

In the last chapter of this tutorial series, we learned how to add a configuration activity for a wearable device. Now we want to configure the watch from our handheld app. So we can add quiet complex configurations.

This article is based on the article "Watchface Wearable Settings". So it is maybe better to read that one first.

Configuration Intent

Just like for the wearable app, we need to add a meta-tag in the watchface service-tag:

<meta-data
 android:name="com.google.android.wearable.watchface.companionConfigurationAction"
 android:value="com.infectedbytes.example.watchface.samplewatch.CONFIG_DIGITAL" />

Instead of wearableConfigurationAction, we need to use companionConfigurationAction.

Handheld Activity

After that we can create our new activity. But this time we have to create it inside the mobile project.

This activity need an intent-filter just like the wearable one. We have to open the manifest file of the mobile project. We then add the following code to the newly created activity-tag:

<intent-filter>
  <action android:name="com.infectedbytes.example.watchface.samplewatch.CONFIG_DIGITAL" />
  <category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
  <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

After that we can recompile our watchface again and run it on our device or emulator. Then we have to recompile the mobile app and install it on our smartphone. To do so, we have to change the build type from wear to mobile.

When both apps are installed correctly, we can open the Android Wear Companion App and we will find a small gear on our watchface preview image.

On the next page, you will find the whole manifest file again.