When I try to share data between android wear emulator(app installed : wear module) and android device (app installed : mobile module), I am checking the number of nodes set using capabilityAPI before sending a message and the result always seem to be 0. My device and wear emulator are always connected.In fact, I am able to send notification from device to wear emulator.Below is the code (obviously called inside a service function),
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.build();
ConnectionResult connectionResult = googleApiClient.blockingConnect(
Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.SECONDS);
if (connectionResult.isSuccess() && googleApiClient.isConnected()) {
CapabilityApi.GetCapabilityResult result = Wearable.CapabilityApi.getCapability(
googleApiClient,
"SHOW DETAILS",
CapabilityApi.FILTER_REACHABLE)
.await(10, TimeUnit.SECONDS);
if (result.getStatus().isSuccess()) {
Set<Node> nodes = result.getCapability().getNodes();
for (Node node : nodes) {
Wearable.MessageApi.sendMessage(
googleApiClient, node.getId(), path, extraInfo.getBytes());
}
} else {
Log.e(TAG, "startDeviceActivityInternal() Failed to get capabilities, status: "
+ result.getStatus().getStatusMessage());
}
googleApiClient.disconnect();
}
Do suggest.
Note: My both modules package name are same.Also , any clarification on how capability name works would be great.