androidwear-oschannel-api

Android Wear MessageApi vs ChannelApi


Android Wear offers multiple ways to synchronize data between the handheld device and the smartwatch. I would like to know when you are supposed to use the MessageApi and when to use the ChannelApi?

When I was first encountered the problem I wanted to use the MessageApi as it is suggested on the Android developer Sending and Receiving Messages website. However, there is written that the MessageApi is not reliability:

Note: A successful result code does not guarantee delivery of the message. If your app requires data reliability, use DataItem objects or the ChannelApi class to send data between devices.

Therefore I use the ChannelApi to send String messages as a byte array between the handheld device and the smartwatch. But why should you even use the MessageApi when it is not reliable?


Solution

  • Use the ChannelApi, if you want to send data in a stream. Use the MessageApi to avoid streams => this has a better performance for small messages.