How do I implement a request-response protocol for an Android Wear 2.0 app?
Scenario:
When I tap on a button on the watch, I want it to fetch some data from the phone and display it on the watch's screen.
What I tried:
I implemented a working example using the MessageApi
, but I don't like it. I send a dummy "request" in one place using one method, I disregard the PendingResult
and then hope that eventually I will receive a message that will be a corresponding response.
Ideally, what I'd like to have is:
byte[] responseBytes = sendRequest(someRequestBytes);