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

前端 未结 5 895
忘了有多久
忘了有多久 2020-12-01 08:24

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 the

5条回答
  •  情歌与酒
    2020-12-01 08:48

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

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

    List 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.

提交回复
热议问题