Search code examples
androidwear-osandroid-wear-data-api

How to know if a message sended from Android wear is received from Android handheld?


here my code, I don't understand why I get success status but the message in not received from handheld because the handheld App is off... How can I know if the message is sended and recived on handheld?

for (Node node : nodes.getNodes()) {
            MessageApi.SendMessageResult result  = Wearable.MessageApi
                    .sendMessage(mGoogleAppiClient, node.getId(), START_ACTIVITY_PATH, canaleByte)
                    .await();
            if (!result.getStatus().isSuccess()) {
                return false;
            } else {
                return true;
            }
}

Solution

  • Your app doesn't need to be "on" to receive a message, just to be installed. If you want to see if the message is received, add a WearableListener on your handheld and add a specific behaviour by overriding the onMessageReceived() method.

    More infos here : https://developer.android.com/training/wearables/data-layer/messages.html and here : https://developer.android.com/reference/com/google/android/gms/wearable/MessageApi.html