When opening a channel via a local node:
Wearable.NodeApi.getLocalNode(googleApiClient)
... the onChannelOpened Listener successfully fires.
However, when opening a channel via a remote node:
Wearable.NodeApi.getConnectedNodes(googleApiClient)
... the onChannelOpened Listener never fires and subsequently can never share files over this channel.
I know openChannel is required for both devices, but the channel listeners are only firing on the device that opened it locally... How does the remote device send or receive files as well if it doesn't know it's connected? Here's breakdown between the two devices
Wearable :
Handle Held :
Toubleshooting
Here are a few things to check:
Are you getting message events or data item updates? If you call Wearable.MessageApi.sendMessage
, do you get onMessageReceived
on the other device? If not, there could be something wrong with how WearableListenerService
is set up on the other node, or with the way your app is packaged (e.g your microapp and app are in different packages, or are signed with different keys).
Are you running the latest version of the Android Wear app? The Channel API was added recently, and it may be that your watch still hasn't received the update to support it. Version 1.1.1.1889093 should be fine.
How to use the Channel API
By the way, it sounds like you can simplify your use of channels. There's no need to open channels both to the local and to the remote node. The way you'd normally use the API is:
Decide whether you want to start the channel from the watch or from the phone. In this case, it sounds like you're starting it from the watch.
In the watch app, call Wearable.ChannelApi.openChannel
, pointing at the phone app. This method returns a PendingResult<OpenChannelResult>
. When it completes successfully, you'll get a Channel
object. This is the watch's side of the channel, and you can use it to send a file.
In the phone app, include a WearableListenerService
, which should get an onChannelOpened
event. That method will be passed a Channel
object, which is the phone's side of the channel. You can call receiveFile
on that object.
So as you can see, you should only have one call to openChannel
: to the remote node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With