I am creating an android wear app that extends push notifications. My app downloads approximately 10 images from a server when a push notification comes in and displays these additional images on the watch. These images are specific to the android wear app and are not shown on the handheld device.
How do I tell if the handheld device is paired with an android wear device so that I can determine if it is necessary to download the additional images required for the wear app?
Thanks!
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.