Wear gist #3:how to start an Activity on the mobile handheld from the Android Wear device

You can start an Activity on the mobile handheld from your Wear device. In order to achieve it you have to:

In your wear activity:
  • connect the GoogleApiClient
  • get the node[1] connected
  • send the message with the Wearable.MessageApi.sendMessage[2]


In your mobile app:
  • register a WearableListenerService
  • start the intent when the message is received

Here a little (and improvable) gist:
https://gist.github.com/gabrielemariotti/117b05aad4db251f7534

[1]:http://developer.android.com/reference/com/google/android/gms/wearable/NodeApi.html#getConnectedNodes(com.google.android.gms.common.api.GoogleApiClient)

[2]:http://developer.android.com/reference/com/google/android/gms/wearable/MessageApi.html#sendMessage(com.google.android.gms.common.api.GoogleApiClient, java.lang.String, java.lang.String, byte[])

Comments

Popular posts from this blog

Snippet: align a TextView around an image

NotificationListenerService and kitkat