com.google.android.gms.wearable.MessageApi |
This interface is deprecated.
Use MessageClient
.
Exposes an API for components to send messages to other nodes.
Messages are delivered to connected network nodes. A message is considered successful if it
has been queued for delivery to the specified node. A message will only be queued if the
specified node is connected. The DataApi
should be used for messages to nodes which are
not currently connected (to be delivered on connection).
Messages should generally contain ephemeral, small payloads. Use assets
with the DataApi
to store more persistent or larger data efficiently.
A message is private to the application that created it and accessible only by that application on other nodes.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MessageApi.FilterType | |||||||||||
MessageApi.MessageListener |
This interface is deprecated.
Use MessageClient.OnMessageReceivedListener .
|
||||||||||
MessageApi.SendMessageResult |
This interface is deprecated.
See sendMessage(String, String, byte[]) .
|
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_MESSAGE_RECEIVED | Message received action for use in manifest-based listener filters. | |||||||||
int | FILTER_LITERAL | Filter type for addListener(GoogleApiClient, MessageListener, Uri, int) : if this
filter is set, the given URI will be taken as a literal path, and the operation will apply to
the matching message only. |
|||||||||
int | FILTER_PREFIX | Filter type for addListener(GoogleApiClient, MessageListener, Uri, int) : if this
filter is set, the given URI will be taken as a path prefix, and the operation will apply to
all matching messages. |
|||||||||
int | UNKNOWN_REQUEST_ID | A value returned by getRequestId() when sendMessage(GoogleApiClient, String, String, byte[]) fails. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers a listener to be notified of received messages.
| |||||||||||
Registers a listener to be notified of received messages.
| |||||||||||
Removes a message listener which was previously added through
addListener(GoogleApiClient, MessageListener) . | |||||||||||
Sends
byte[] data to the specified node. |
Message received action for use in manifest-based listener filters.
See also:
Filter type for addListener(GoogleApiClient, MessageListener, Uri, int)
: if this
filter is set, the given URI will be taken as a literal path, and the operation will apply to
the matching message only.
Filter type for addListener(GoogleApiClient, MessageListener, Uri, int)
: if this
filter is set, the given URI will be taken as a path prefix, and the operation will apply to
all matching messages.
A value returned by getRequestId()
when sendMessage(GoogleApiClient, String, String, byte[])
fails.
Registers a listener to be notified of received messages. Calls to this method should be
balanced with removeListener(GoogleApiClient, MessageListener)
to avoid leaking
resources.
uri
and filterType
can be used to filter the messages sent to the listener.
For example, if uri
and filterType
create a path prefix filter, then only
messages matching that prefix will be notified. The uri
follows the rules of the <data>
element of <intent-filter>. The path is ignored if a URI host is not specified. The host
should be an Android Wear node ID, or * to match any node. i.e, you should use:
wear://*/<path>or
wear://<nodeId>/<path>
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 |
GoogleApiClient |
listener |
MessageApi.MessageListener |
uri |
Uri |
filterType |
int |
Returns | |
---|---|
PendingResult<Status> |
Registers a listener to be notified of received messages. Calls to this method should be
balanced with removeListener(GoogleApiClient, MessageListener)
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 |
GoogleApiClient |
listener |
MessageApi.MessageListener |
Returns | |
---|---|
PendingResult<Status> |
Removes a message listener which was previously added through addListener(GoogleApiClient, MessageListener)
.
Parameters | |
---|---|
client |
GoogleApiClient |
listener |
MessageApi.MessageListener |
Returns | |
---|---|
PendingResult<Status> |
Sends byte[]
data to the specified node.
Parameters | |
---|---|
client |
GoogleApiClient |
nodeId |
String : identifier for a particular node on the Android Wear network. Valid targets may
be obtained through getConnectedNodes(GoogleApiClient) or from the host in
getUri() . |
path |
String : identifier used to specify a particular endpoint at the receiving node |
data |
byte : small array of information to pass to the target node. Generally not larger than
100k |
Returns | |
---|---|
PendingResult<MessageApi.SendMessageResult> |
a PendingResult that is set when the message is queued to be sent. A successful
result doesn't guarantee delivery.
|