2

From a Wear app I'm trying to constantly check if the Wear device is connected to the Handheld device. We can do that through Wearable.getNodeClient(context).connectedNodes. Is there any way to add a listener to that data? Also, is there any way to make sure any of these nodes is a Handheld device?

Using the CapabilityClient we can know if the app is installed by adding a capability to the wear.xml file in the Handheld app. I am not looking to check that.

I've also seen this question, but it doesn't answer mine.

Damia Fuentes
  • 5,308
  • 6
  • 33
  • 65

1 Answers1

2

Yes, you can add an ACTION_CAPABILITY_CHANGED action to the manifest and then add a CapabilityClient listener. Within your OnCapabilityChangedListener you can then check getNodes() from the passed in CapabilityInfo to obtain an updated list of available modes. As for checking if it's a handheld or a watch, you should already have different capability strings for each, so you can simply filter the node set on the one you've set for the handheld.

Paul Mundt
  • 459
  • 6
  • 9