Skip to content Skip to sidebar Skip to footer

Android Wearables: How To Handle The Event Of A Connected Device?

From the smartwatch I'd like to intercept the event of the connection to a smartphone. This is automatically managed by Android and Android Wear so I need to get this event from my

Solution 1:

to exchange data between the wearable and the handheld app I strongly suggest you to use the Wearable.DataApi or the Wearable.MessageApi. You will probably want to to have a subclass of WearableListenerService running on both side, and handling the communication onDataChanged/onMessageReceived. They have an empty implementation on the super class. So you have to override the one you need. If you use the DataApi you'll have to override onDataChanged, onMessageReceived otherwise.

Do I have to start it or is it automatically running in background

you have to declare your subclass in the manifest, and use BIND_LISTENER as action,

<intent-filter><actionandroid:name="com.google.android.gms.wearable.BIND_LISTENER"/></intent-filter>

Android takes care of the rest.

Post a Comment for "Android Wearables: How To Handle The Event Of A Connected Device?"