How to Detect If Android Device Is Paired with Android Wear Watch

How to detect if android device is paired with android wear watch

You need to use the NodeApi, in particular NodeApi.getConnectedNodes().

For example (from a background thread -- otherwise use setResultCallback() and not await()):

List<Node> connectedNodes =
Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await().getNodes();

If the list of nodes returned contains at least one element, then there is a connected Android Wear device, otherwise there isn't.


Update: With the release of Google Play Services 7.3, support for multiple Android Wear devices connected simultaneously has been added. You can use the CapabilityApi to request nodes with specific capabilities.

Detecting connected/disconnected android wear device

Why not using CapabilitApi? If your app on the mobile provides a certain capability that you are interested in, you can use these apis to query for the nodes (connected and nearby) that provide that capability. Isn't that what you want?

kotlin: What is the best way to know if there is a wearos device connected to the phone and if it has a specific app installed?

You should be able to use the NodeClient to see if there is a wear device connected to your mobile.

https://developers.google.com/android/reference/com/google/android/gms/wearable/NodeClient

And then use CapabilityClient to see if you app is installed and advertising and agreed capability.

https://developers.google.com/android/reference/com/google/android/gms/wearable/CapabilityClient

If it's an unrelated app then you likely can't check whether it is installed remotely.

Detecting connected watch version

There's not a good way to do this right now. It's been discussed a couple of times on the Wear developers G+ community, and the best we came up with is:

  1. Go ahead and send the RemoteIntent to open the Play store.
  2. Attach a RemoteIntent.ResultReceiver when you do so.
  3. If the watch is running Wear 1.x, this will return with a resultCode of RESULT_FAILED, and you can show your user a message accordingly.

This is obviously not ideal; it involves a useless step (trying to open the Play store) for 1.x users, and there's also no way to distinguish any other possible failure modes. But as of today, it's the best we have.

Discussions:

https://plus.google.com/+SterlingUdell/posts/XJZ8mAsaZ8B
https://plus.google.com/u/0/+SterlingUdell/posts/WWBVxjcD7vT

Check android wear and mobile connection status

Wearable.NodeApi.getConnectedNodes returns a list of Nodes representing either the connected handheld (if called from the Wear app) or connected Wear devices (if called on the handheld). The list should be empty if there is no connection. Google has a short example here.



Related Topics



Leave a reply



Submit