com.google.android.gms.wearable.ChannelApi |
Client interface for Wearable Channel API. Allows apps on a wearable device to send and receive data from other wearable nodes.
Channels are bidirectional. Each side, both the initiator and the receiver may both read and
write to the channel by using getOutputStream(GoogleApiClient)
and
getInputStream(GoogleApiClient)
. Once a channel is established, the API
for the initiator and receiver are identical.
Channels are only available when the wearable nodes are connected. When the remote node
disconnects, all existing channels will be closed. Any listeners (added through
addListener(GoogleApiClient, ChannelListener)
and any installed
WearableListenerService
) will be notified of the channel closing.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ChannelApi.ChannelListener | A listener which will be notified on changes to channels. | ||||||||||
ChannelApi.CloseReason |
An annotation for values passed to onChannelClosed(Channel, int, int) , and other methods
on the ChannelApi.ChannelListener interface.
|
||||||||||
ChannelApi.OpenChannelResult |
Result of openChannel(GoogleApiClient, String, String) .
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers a listener to be notified of channel events.
| |||||||||||
Opens a channel to exchange data with a remote node.
| |||||||||||
Removes a listener which was previously added through
addListener(GoogleApiClient, ChannelListener) .
|
Registers a listener to be notified of channel events. Calls to this method should
balanced with removeListener(GoogleApiClient, ChannelListener)
to avoid leaking
resources.
Callers wishing to be notified of events in the background should use
WearableListenerService
.
client | a connected client |
---|---|
listener | a listener which will be notified of changes to any channel |
Opens a channel to exchange data with a remote node.
Channel which are no longer needed should be closed using
close(GoogleApiClient)
.
This call involves a network round trip, so may be long running. client
must
remain connected during that time, or the request will be cancelled (like any other Play
Services API calls).
client | a connected client |
---|---|
nodeId | the node ID of a wearable node, as returned from
getConnectedNodes(GoogleApiClient) |
path | an app-specific identifier for the channel |
Removes a listener which was previously added through
addListener(GoogleApiClient, ChannelListener)
.
client | a connected client |
---|---|
listener | a listener which was added using
addListener(GoogleApiClient, ChannelListener)
|