ChannelApi

public interface ChannelApi

This interface was deprecated.
Use ChannelClient.

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 Class Summary

interface ChannelApi.ChannelListener This interface was deprecated. Use ChannelClient.ChannelCallback.  
@interface ChannelApi.CloseReason An annotation for values passed to onChannelClosed(Channel, int, int), and other methods on the ChannelApi.ChannelListener interface. 
interface ChannelApi.OpenChannelResult This interface was deprecated. See openChannel(String, String).  

Constant Summary

String ACTION_CHANNEL_EVENT Channel action for use in listener filters.

Public Method Summary

abstract PendingResult<Status>
addListener(GoogleApiClient client, ChannelApi.ChannelListener listener)
Registers a listener to be notified of channel events.
abstract PendingResult<ChannelApi.OpenChannelResult>
openChannel(GoogleApiClient client, String nodeId, String path)
Opens a channel to exchange data with a remote node.
abstract PendingResult<Status>
removeListener(GoogleApiClient client, ChannelApi.ChannelListener listener)
Removes a listener which was previously added through addListener(GoogleApiClient, ChannelListener).

Constants

public static final String ACTION_CHANNEL_EVENT

Channel action for use in listener filters.

Constant Value: "com.google.android.gms.wearable.CHANNEL_EVENT"

Public Methods

public abstract PendingResult<Status> addListener (GoogleApiClient client, ChannelApi.ChannelListener listener)

Registers a listener to be notified of channel events. Calls to this method should be balanced with calls to removeListener(GoogleApiClient, ChannelListener) to avoid leaking resources.

Listener events will be called on the main thread, or the handler specified on client when it was built (using setHandler(Handler)).

Callers wishing to be notified of events in the background should use WearableListenerService.

Parameters
client a connected client
listener a listener which will be notified of changes to any channel

public abstract PendingResult<ChannelApi.OpenChannelResult> openChannel (GoogleApiClient client, String nodeId, String path)

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).

Parameters
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

public abstract PendingResult<Status> removeListener (GoogleApiClient client, ChannelApi.ChannelListener listener)

Removes a listener which was previously added through addListener(GoogleApiClient, ChannelListener).

Parameters
client a connected client
listener a listener which was added using addListener(GoogleApiClient, ChannelListener)