java.lang.Object | ||
↳ | com.google.android.gms.common.api.GoogleApi<com.google.android.gms.wearable.Wearable.WearableOptions> | |
↳ | com.google.android.gms.wearable.CapabilityClient |
Exposes an API to learn about capabilities provided by nodes on the Wear network.
Capabilities are local to an application.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CapabilityClient.CapabilityFilterType | Capability filter types. | ||||||||||
CapabilityClient.NodeFilterType | Node filter types. | ||||||||||
CapabilityClient.OnCapabilityChangedListener | Listener for changes in the reachable nodes providing a capability. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ACTION_CAPABILITY_CHANGED | Capability changed action for use in manifest-based listener filters. | |||||||||
int | FILTER_ALL | Filter type for getCapability(String, int) , getAllCapabilities(int) : If this filter is set then the full set of nodes that declare
the given capability will be included in the capability's CapabilityInfo . |
|||||||||
int | FILTER_LITERAL | Filter type for addListener(OnCapabilityChangedListener, 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 capability only. |
|||||||||
int | FILTER_PREFIX | Filter type for addListener(OnCapabilityChangedListener, 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
capabilities. |
|||||||||
int | FILTER_REACHABLE | Filter type for getCapability(String, int) , getAllCapabilities(int) : If this filter is set then only reachable nodes that declare
the given capability will be included in the capability's CapabilityInfo . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Registers a listener to be notified of a specific capability being added to or removed from the
Wear network.
| |||||||||||
Registers a listener to be notified of capabilities being added to or removed from the Wear
network.
| |||||||||||
Announces that a capability has become available on the local node.
| |||||||||||
Returns information about all capabilities, including the nodes that declare those
capabilities.
| |||||||||||
Returns information about a capability, including the nodes that declare that capability.
| |||||||||||
Removes a listener which was previously added through
addListener(OnCapabilityChangedListener, Uri, int) . | |||||||||||
Removes a listener which was previously added through
addListener(OnCapabilityChangedListener, String) . | |||||||||||
Announces that a capability is no longer available on the local node.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Capability changed action for use in manifest-based listener filters.
Capability events do not support filtering by host, but can be filtered by path.
See also:
Filter type for getCapability(String, int)
, getAllCapabilities(int)
: If this filter is set then the full set of nodes that declare
the given capability will be included in the capability's CapabilityInfo
.
Filter type for addListener(OnCapabilityChangedListener, 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 capability only.
Filter type for addListener(OnCapabilityChangedListener, 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
capabilities.
Filter type for getCapability(String, int)
, getAllCapabilities(int)
: If this filter is set then only reachable nodes that declare
the given capability will be included in the capability's CapabilityInfo
.
Registers a listener to be notified of a specific capability being added to or removed from the
Wear network. Calls to this method should be balanced with removeListener(OnCapabilityChangedListener, String)
to avoid leaking resources.
Listeners will be called on the main thread, or the looper set in Wearable.WearableOptions
.
Callers wishing to be notified of events in the background should use WearableListenerService
.
Parameters | |
---|---|
listener |
CapabilityClient.OnCapabilityChangedListener |
capability |
String |
Returns | |
---|---|
Task<Void> |
Registers a listener to be notified of capabilities being added to or removed from the Wear
network. Calls to this method should be balanced with removeListener(OnCapabilityChangedListener)
to avoid leaking resources.
uri
and filterType
can be used to filter the capability changes sent to the
listener. For example, if uri
and filterType
create a prefix filter, then only
capabilities 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. To match
capabilities by name or name prefix, the host must be *
. i.e:
wear://*/<capability_name>
Listeners will be called on the main thread, or the looper set in Wearable.WearableOptions
.
Callers wishing to be notified of events in the background should use WearableListenerService
.
Parameters | |
---|---|
listener |
CapabilityClient.OnCapabilityChangedListener |
uri |
Uri |
filterType |
int |
Returns | |
---|---|
Task<Void> |
Announces that a capability has become available on the local node.
Parameters | |
---|---|
capability |
String |
Returns | |
---|---|
Task<Void> |
Returns information about all capabilities, including the nodes that declare those
capabilities. The filter parameter controls whether all nodes are returned, FILTER_ALL
, or only those that are currently reachable by this node, FILTER_REACHABLE
.
The local node will never be returned in the set of nodes.
Parameters | |
---|---|
nodeFilter |
int |
Returns | |
---|---|
Task<Map<String, CapabilityInfo>> |
Returns information about a capability, including the nodes that declare that capability. The
filter parameter controls whether all nodes are returned, FILTER_ALL
, or only those
that are currently reachable by this node, FILTER_REACHABLE
.
The local node will never be returned in the set of nodes.
Parameters | |
---|---|
capability |
String |
nodeFilter |
int |
Returns | |
---|---|
Task<CapabilityInfo> |
Removes a listener which was previously added through addListener(OnCapabilityChangedListener, Uri, int)
. The listener will continue to receive
events for capabilities it was previously registered for with addListener(OnCapabilityChangedListener, String)
, until those instances are removed.
Parameters | |
---|---|
listener |
CapabilityClient.OnCapabilityChangedListener |
Returns | |
---|---|
Task<Boolean> |
Removes a listener which was previously added through addListener(OnCapabilityChangedListener, String)
. The listener is only removed from listening
for the capability provided. All other instances of this listener will continue to receive
events until they are also removed.
Parameters | |
---|---|
listener |
CapabilityClient.OnCapabilityChangedListener |
capability |
String |
Returns | |
---|---|
Task<Boolean> |
Announces that a capability is no longer available on the local node. Note: this will not remove any capabilities announced in the Manifest for an app.
Parameters | |
---|---|
capability |
String |
Returns | |
---|---|
Task<Void> |