I'm following the android wear documentation to send messages from one device to another (https://developer.android.com/training/wearables/data-layer/messages.html)
but I think there's some error in the examples because the send message method throws an IllegalStateException with the following message: await must not be called on the UI thread
How can I fix it?
You can't do that because await()
blocks the thread.
You want to do this using an asynchronous thread, using for example an AsyncTask
, like suggested in the Google Play Services documentation here: https://developer.android.com/google/auth/api-client.html#Sync
And yes, the documentation should be updated to explicate to do tha same for the Wear Api.