Android Wear + Wearable ChannelApi + How to open connection to cloud node (WIFI)? -
the connection via bluetooth using new channel api working should, if switch cloud node (wifi mode) channel can't opened. result null , running timeout.
channelapi.openchannelresult result = wearable.channelapi.openchannel(googleapiclient, "cloud", constants.copy_file_via_channel_path).await();
is right way establish wifi connection between nodes , there somewhere example how implement this?
update:
on watch: (afterwards send nodeid phone via message. used approach after seeing problems thread android wear + wearable channelapi openchannel not opening remote node?)
on watch: (send retrieved localnodeid phone)
nodeapi.getlocalnoderesult localnoderesult = wearable.nodeapi.getlocalnode(googleapiclient).await();
on phone:
channelapi.openchannelresult result = wearable.channelapi.openchannel(googleapiclient, localnodeid, constants.copy_file_via_channel_path).await(); channel.getoutputstreamresult getoutputstreamresult = channel.getoutputstream(googleapiclient).await(); outputstream outputstream = getoutputstreamresult.getoutputstream(); outputstream.write(bytechunk); outputstream.close();
on watch:
@override public void onchannelopened(channel channel) { if (channel.getpath() .equals(constants.copy_file_via_channel_path)) { new savedatafromchanneltask(channel).execute(); } } protected class savedatafromchanneltask extends asynctask<void, void, void> { private final channel channel; public savedatafromchanneltask(channel channel) { this.channel = channel; } @override protected void doinbackground(void... params) { channel.getinputstreamresult getinputstreamresult = channel.getinputstream(googleapiclient) .await(); inputstream inputstream = getinputstreamresult.getinputstream(); savefiletodisk(inputstream); return null; } }
this implementation inside "wear media" app, using channel api. inside settings chunksize can modified byte value between 1000 , 9999999, during transfer , activated bluetooth , wifi bluetooth connection used.
"cloud"
not valid node id - need use node id of device such phone or android wear device. devices automatically switch bluetooth wifi based on underlying connection - there nothing need do. can use capabilityapi, similar sending messages training, correctly determine node id open channel with.
Comments
Post a Comment