androidwear-oswatch-face-api

RemoteActivityHelper.startRemoteActivity not working with Android Wear OS 4 Emulator


I am developing a companion app for my Android Wear OS watch face. I am trying to use the startRemoteActivity method to launch Google Play store an a watch, where a user can download the watch face (a pretty typical thing for a watch face companion app to do).

However, calling startRemoteActivity method to open the store on a Wear OS 4 emulator does not work (it works okay in combination with a Wear OS 3 emulator and a physical device). It does not throw any exception, it just does not execute anything. The call of the function simply never completes, code execution gets stuck forever on the startRemoteActivity line. Below, you can see my code, but I doubt anything is wrong with it (continue reading, to see why I think so).

I installed 3rd party watch face companion apps on my phone and they also do not seem to work with the Wear OS 4 emulator. They detect the connected/paired watch (same as my companion app) but then when it's time to start a remote activity (typically to open a Google Play store), nothing happens (again, same as in my app).

Has anyone else noticed anything similar? Does startRemoteActivity method of the RemoteActivityHelper work for you guys in combination with the Wear OS 4 emulator?

I have the latest macOS Hedgehog version of Android Studio installed, along with the latest Emulator, tools, and whatnot.

            val connectedNodes = nodeClient.connectedNodes.await()
            if (connectedNodes.isEmpty())
                return false

            val intent = Intent(Intent.ACTION_VIEW)
                .addCategory(Intent.CATEGORY_DEFAULT)
                .addCategory(Intent.CATEGORY_BROWSABLE)
                .setData(Uri.parse(storeLink))

            var startedStoreOnAtLeastOneDevice = false
            var atLeastOneNodeReportedAnError = false

            for (node in connectedNodes) {
                try {
                    remoteActivityHelper
                        .startRemoteActivity(
                            targetIntent = intent,
                            targetNodeId = node.id
                        ).await()

                    startedStoreOnAtLeastOneDevice = true
                } catch (t: Throwable) {
                    atLeastOneNodeReportedAnError = true
                }
            }

Solution

  • Solved the problem. If anyone else stumbles across the same issue, upgrading "Wear OS by Google" app in the emulator solves the problem. Here are the steps:

    1. Open Play Store app on the Wear OS 4 emulator.
    2. Scroll all the way down and select the Manage apps option (2nd from the bottom).
    3. Install all available updates (in my case, the emulator had 6 pending updates, "Wear OS by Google" being the important one).