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

Data Stream from Wearable to Android Handheld


What is the best way to send a data stream from the wearable to the phone? I have a watch which generates a constant stream of data, which I want to send to the phone. None of the data packets should get lost. That means data needs to be chached as long as there is no phone connected. Both mechanism of the Wearable Data Layer do not really suit my needs as far as I understand:

  • Messages: unreliable, if handheld is disconnected the data gets lost
  • DataItem: every data point would need a unique path, what seems rather inpractical and I would have to delete the data item afterwards.

I am just new to wearable development, maybe the answer is kind of obvious and I just can't see it-


Solution

  • You have to use the ChannelAPI. You can find the documentation here.

    It is meant to be used to send large files but you can also open an InputStream in a device and an OutputStream in an other (see getInputStream).

    I have already used that in a test project to stream touch events or accelerometer data and it works great (with a small latency though).