Android Wear watchface companion configuration testing in emulator

641 views Asked by At

I'm having some issues testing/using my handheld companion configuration activity for an Android Wear watchface I am developing. While I'm not new to Android development in general, this is my first watchface application, so if some of these questions are obvious, please refer me to the appropriate documentation.

I have my wearable module and a handheld module. Currently the handheld module only has a single activity as the companion configuration.

The two questions I have are this:

  1. When testing/debugging through the wear emulator connected to a handheld device connected via USB to the computer, how can I launch the companion configuration activity? When selecting a watchface on the wear device, no "gear" icon appears (however, I assume this is because there is no wearable configuration activity, just a companion configuration activity, but I could be wrong, of course).

On the handheld device inside of the Android Wear application the three pips on the watchface has a menu item for "Install Settings App" but this option just launches the play store and, naturally, can't find any settings app to install. How can I launch the settings/companion configuration activity on the handheld device.

  1. How do I test/debug these modules on my actual devices? I'd like to just load the handheld module onto my phone device through Android Studio and have it load the wearable module onto the connected wear device. What are the proper steps to accomplish this because I don't seem to be able to do it?

I assumed that I choose the handheld module activity and then Run. In the device chooser I'm choose the connected handheld device and everything seems to run to completion, but no watchface shows up inside the Android Wear application on the device or on the physical wear device.

**** UPDATE ****

I seem to be able to run the companion configuration fine when I load the app onto an actual wearable devices connected via bluetooth debugging

adb forward tcp:4444 localabstract:/adb-hub
adb connect localhost:4444

Still not via the emulator yet (if that is possible)

For reference, here are the manifest files. I have sanitized a few pieces of data just for privacy on this project, but nothing of consequence should be missing.

Wearable manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.FOOBAR.android.FOOBAR" >

    <uses-feature android:name="android.hardware.type.watch" />

    <!-- Required to act as a custom watch face. -->
    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.DeviceDefault" >
        <service
            android:name=".WatchfaceService"
            android:label="@string/my_analog_name"
            android:permission="android.permission.BIND_WALLPAPER" >
            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/watch_face" />
            <meta-data
                android:name="com.google.android.wearable.watchface.preview"
                android:resource="@drawable/preview_accuweather" />
            <meta-data
                android:name="com.google.android.wearable.watchface.preview_circular"
                android:resource="@drawable/preview_accuweather" />
            <meta-data
                android:name="com.google.android.wearable.watchface.companionConfigurationAction"
                android:value="com.FOOBAR.android.FOOBAR.watchface.CONFIG_HANDHELD" />

            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
                <category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
            </intent-filter>
        </service>

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

</manifest>

Handheld manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.FOOBAR.android.FOOBAR" >

    <uses-sdk android:minSdkVersion="18"
        android:targetSdkVersion="21" />

    <!-- Permissions required by the wearable app -->
    <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <!-- All intent-filters for config actions must include the categories
        com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION and
        android.intent.category.DEFAULT. -->
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".HandheldConfig"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.FOOBAR.android.FOOBAR.watchface.CONFIG_HANDHELD" />
                <category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <!--
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
            -->
    </application>

</manifest>
1

There are 1 answers

1
user5039278 On

im working on some Android Wear app now, for your 2 questions, i hope my answer can help you:

  1. I think you should check if the phone connect via USB cable is paired with your wear emulator, in my opinion, those device does not pair with each other.

  2. Im using Eclipse to develop the wear app, so in my case, just run the wear app directly on Eclipse and it will install the app to the wear emulator (Android Virtual Device).

One thing i want you to know is watchfaces only available on watch have firmware 5.0 and above, so make sure when you create the wear emulator, you should choose the device's target is at least 5.0.1 otherwise you will not see your watchface there