0

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;
            }
}
alfo888_ibg
  • 1,847
  • 5
  • 25
  • 43

2 Answers2

1

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

Tony Malghem
  • 222
  • 2
  • 11
0

I think you can use the onPeerConnected() method from WearableListenerService to check if both devices are connected, before you send the message to your handheld. So you wont send message to your handheld, if it is off.

You can read the documentation of WearableListenerService.

ztan
  • 6,861
  • 2
  • 24
  • 44