/** * Find the connected nodes that provide at least one of the given capabilities */ private void showNodes(final String... capabilityNames) { Task<Map<String, CapabilityInfo>> capabilitiesTask = Wearable.getCapabilityClient(this) .getAllCapabilities(CapabilityClient.FILTER_REACHABLE); capabilitiesTask.addOnSuccessListener(new OnSuccessListener<Map<String, CapabilityInfo>>() { @Override public void onSuccess(Map<String, CapabilityInfo> capabilityInfoMap) { Set<Node> nodes = new HashSet<>(); if (capabilityInfoMap.isEmpty()) { showDiscoveredNodes(nodes); return; } for (String capabilityName : capabilityNames) { CapabilityInfo capabilityInfo = capabilityInfoMap.get(capabilityName); if (capabilityInfo != null) { nodes.addAll(capabilityInfo.getNodes()); } } showDiscoveredNodes(nodes); } }); }
@Override public void onResume() { super.onResume(); mDataItemGeneratorFuture = mGeneratorExecutor.scheduleWithFixedDelay( new DataItemGenerator(), 1, 5, TimeUnit.SECONDS); mStartActivityBtn.setEnabled(true); mSendPhotoBtn.setEnabled(mCameraSupported); // Instantiates clients without member variables, as clients are inexpensive to create and // won't lose their listeners. (They are cached and shared between GoogleApi instances.) Wearable.getDataClient(this).addListener(this); Wearable.getMessageClient(this).addListener(this); Wearable.getCapabilityClient(this) .addListener( this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE); }
@Override public void onCreate() { super.onCreate(); LOGD(TAG, "onCreate"); Wearable.getMessageClient(this).addListener(this); Wearable.getCapabilityClient(this) .addListener( this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE); Thread mBackgroundThread = new BackgroundThread(); mBackgroundThread.start(); }
private void loadNodes() { Task<CapabilityInfo> capabilityTask = Wearable.getCapabilityClient(this) .getCapability(CORDOVA_CAPABILITY, CapabilityClient.FILTER_REACHABLE); capabilityTask.addOnSuccessListener(new OnSuccessListener<CapabilityInfo>() { @Override public void onSuccess(CapabilityInfo capabilityInfo) { WearProviderService.this.onCapabilityChanged(capabilityInfo); } }); }
@Override protected void onResume() { super.onResume(); // Instantiates clients without member variables, as clients are inexpensive to create and // won't lose their listeners. (They are cached and shared between GoogleApi instances.) Wearable.getDataClient(this).addListener(this); Wearable.getMessageClient(this).addListener(this); Wearable.getCapabilityClient(this) .addListener( this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE); }