Java Code Examples for com.google.android.gms.wearable.CapabilityInfo#getNodes()
The following examples show how to use
com.google.android.gms.wearable.CapabilityInfo#getNodes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainMobileActivity.java From wear-os-samples with Apache License 2.0 | 5 votes |
public void onCapabilityChanged(CapabilityInfo capabilityInfo) { Log.d(TAG, "onCapabilityChanged(): " + capabilityInfo); mWearNodesWithApp = capabilityInfo.getNodes(); // Because we have an updated list of devices with/without our app, we need to also update // our list of active Wear devices. findAllWearDevices(); verifyNodeAndUpdateUI(); }
Example 2
Source File: LoggingUtil.java From APDE with GNU General Public License v2.0 | 5 votes |
private static void updateBestNode(Context context) { bestNodeId = null; try { CapabilityInfo info = Tasks.await(Wearable.getCapabilityClient(context).getCapability("apde_receive_logs", CapabilityClient.FILTER_REACHABLE)); for (Node node : info.getNodes()) { if (node.isNearby()) { bestNodeId = node.getId(); } } } catch (Exception e) { // Don't call printStackTrace() because that would make an infinite loop Log.e("apde", e.toString()); } }
Example 3
Source File: WearDataLayerListenerService.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onCapabilityChanged(CapabilityInfo capabilityInfo) { if ("remote_notifications".equals(capabilityInfo.getName())) { watchConnected = false; for (Node node : capabilityInfo.getNodes()) { if (node.isNearby()) watchConnected = true; } } }
Example 4
Source File: QuizReportActionService.java From android-Quiz with Apache License 2.0 | 5 votes |
private void sendResetMessage(GoogleApiClient googleApiClient, CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); if (connectedNodes.isEmpty()) { Log.w(TAG, "No node capable of resetting quiz was found"); } else { for (Node node : connectedNodes) { Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), RESET_QUIZ_PATH, new byte[0]); } } }
Example 5
Source File: DisconnectListenerService.java From android-FindMyPhone with Apache License 2.0 | 5 votes |
private void updateFindMeCapability(CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); if (connectedNodes.isEmpty()) { setupLostConnectivityNotification(); } else { for (Node node : connectedNodes) { // we are only considering those nodes that are directly connected if (node.isNearby()) { ((NotificationManager) getSystemService(NOTIFICATION_SERVICE)) .cancel(FORGOT_PHONE_NOTIFICATION_ID); } } } }
Example 6
Source File: ListenerService.java From AndroidAPS with GNU Affero General Public License v3.0 | 5 votes |
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) { // Log.d(TAG, "CapabilityInfo: " + capabilityInfo); Set<Node> connectedNodes = capabilityInfo.getNodes(); return pickBestNode(connectedNodes); // mPhoneNodeId = pickBestNodeId(connectedNodes); }
Example 7
Source File: WearDataLayerListenerService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onCapabilityChanged(CapabilityInfo capabilityInfo){ if("remote_notifications".equals(capabilityInfo.getName())){ watchConnected=false; for(Node node:capabilityInfo.getNodes()){ if(node.isNearby()) watchConnected=true; } } }
Example 8
Source File: WearDataLayerListenerService.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onCapabilityChanged(CapabilityInfo capabilityInfo){ if("remote_notifications".equals(capabilityInfo.getName())){ watchConnected=false; for(Node node:capabilityInfo.getNodes()){ if(node.isNearby()) watchConnected=true; } } }
Example 9
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 4 votes |
@Override protected Void doInBackground(Void... voids) { if (googleApiClient.isConnected()) { if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period lastRequest = System.currentTimeMillis(); //NodeApi.GetConnectedNodesResult nodes = // Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName(); CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi.getCapability( googleApiClient, CAPABILITY_WEAR_APP, CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS); CapabilityInfo nodes; if (!capabilityResult.getStatus().isSuccess()) { Log.e(TAG, "doInBackground Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage()); nodes = null; } else { nodes = capabilityResult.getCapability(); } SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit(); boolean enable_wearG5 = sharedPrefs.getBoolean("enable_wearG5", false); boolean force_wearG5 = sharedPrefs.getBoolean("force_wearG5", false); String node_wearG5 = mPrefs.getString("node_wearG5", ""); if (nodes != null && nodes.getNodes().size() > 0) { updateWearSyncBgsCapability(nodes); int count = nodes.getNodes().size(); Log.d(TAG, "doInBackground connected. CapabilityApi.GetCapabilityResult mWearNodeID=" + (mWearNodeId != null ? mWearNodeId : "") + " count=" + count);//KS boolean isConnectedToWearable = false; for (Node peer : nodes.getNodes()) { //onPeerConnected String wearNode = peer.getDisplayName() + "|" + peer.getId(); Log.d(TAG, "CheckWearableConnected onPeerConnected peer name & ID: " + wearNode); if (wearNode.equals(node_wearG5)) { isConnectedToWearable = true; sendPrefSettings(); break; } else if (node_wearG5.equals("")) { isConnectedToWearable = true; prefs.putString("node_wearG5", wearNode); prefs.apply(); break; } } sendPrefSettings(); initWearData(); if (enable_wearG5) { //Only stop service if Phone will rely on Wear Collection Service if (force_wearG5 && isConnectedToWearable) { Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear BT Collector"); stopBtService(); } else { Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=false Phone startBtService"); startBtService(); } } } else { //onPeerDisconnected Log.d(TAG, "CheckWearableConnected onPeerDisconnected"); if (sharedPrefs.getBoolean("wear_sync", false)) { Log.d(TAG, "CheckWearableConnected onPeerDisconnected wear_sync=true Phone startBtService"); startBtService(); } } } else { Log.d(TAG, "Debounce limit hit - not sending"); } } else { Log.d(TAG, "Not connected for sending"); googleApiClient.connect(); } return null; }
Example 10
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); return pickBestNode(connectedNodes); //mPhoneNodeId = pickBestNodeId(connectedNodes); }
Example 11
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
private void updateWearSyncBgsCapability(CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); mWearNodeId = pickBestNodeId(connectedNodes); }
Example 12
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 4 votes |
@Override protected Void doInBackground(Void... voids) { if (googleApiClient.isConnected()) { if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period lastRequest = System.currentTimeMillis(); //NodeApi.GetConnectedNodesResult nodes = // Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName(); CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi.getCapability( googleApiClient, CAPABILITY_WEAR_APP, CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS); CapabilityInfo nodes; if (!capabilityResult.getStatus().isSuccess()) { Log.e(TAG, "doInBackground Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage()); nodes = null; } else { nodes = capabilityResult.getCapability(); } SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit(); boolean enable_wearG5 = sharedPrefs.getBoolean("enable_wearG5", false); boolean force_wearG5 = sharedPrefs.getBoolean("force_wearG5", false); String node_wearG5 = mPrefs.getString("node_wearG5", ""); if (nodes != null && nodes.getNodes().size() > 0) { updateWearSyncBgsCapability(nodes); int count = nodes.getNodes().size(); Log.d(TAG, "doInBackground connected. CapabilityApi.GetCapabilityResult mWearNodeID=" + (mWearNodeId != null ? mWearNodeId : "") + " count=" + count);//KS boolean isConnectedToWearable = false; for (Node peer : nodes.getNodes()) { //onPeerConnected String wearNode = peer.getDisplayName() + "|" + peer.getId(); Log.d(TAG, "CheckWearableConnected onPeerConnected peer name & ID: " + wearNode); if (wearNode.equals(node_wearG5)) { isConnectedToWearable = true; sendPrefSettings(); break; } else if (node_wearG5.equals("")) { isConnectedToWearable = true; prefs.putString("node_wearG5", wearNode); prefs.apply(); break; } } sendPrefSettings(); initWearData(); if (enable_wearG5) { //Only stop service if Phone will rely on Wear Collection Service if (force_wearG5 && isConnectedToWearable) { Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear BT Collector"); stopBtService(); } else { Log.d(TAG, "CheckWearableConnected onPeerConnected force_wearG5=false Phone startBtService"); startBtService(); } } } else { //onPeerDisconnected Log.d(TAG, "CheckWearableConnected onPeerDisconnected"); if (sharedPrefs.getBoolean("wear_sync", false)) { Log.d(TAG, "CheckWearableConnected onPeerDisconnected wear_sync=true Phone startBtService"); startBtService(); } } } else { Log.d(TAG, "Debounce limit hit - not sending"); } } else { Log.d(TAG, "Not connected for sending"); googleApiClient.connect(); } return null; }
Example 13
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 4 votes |
private void updateWearSyncBgsCapability(CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); mWearNodeId = pickBestNodeId(connectedNodes); }
Example 14
Source File: WatchUpdaterService.java From AndroidAPS with GNU Affero General Public License v3.0 | 4 votes |
private void updateWearSyncBgsCapability(CapabilityInfo capabilityInfo) { Log.d("WatchUpdaterService", logPrefix + "CabilityInfo: " + capabilityInfo); Set<Node> connectedNodes = capabilityInfo.getNodes(); mWearNodeId = pickBestNodeId(connectedNodes); }
Example 15
Source File: MessageApiHandler.java From PowerSwitch_Android with GNU General Public License v3.0 | 4 votes |
private void updateReceiverActionTriggerCapability(CapabilityInfo capabilityInfo) { connectedNodes = capabilityInfo.getNodes(); }
Example 16
Source File: ListenerService.java From xDrip with GNU General Public License v3.0 | 4 votes |
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) { Set<Node> connectedNodes = capabilityInfo.getNodes(); return pickBestNode(connectedNodes); //mPhoneNodeId = pickBestNodeId(connectedNodes); }
Example 17
Source File: MainPhoneActivity.java From wear-os-samples with Apache License 2.0 | 4 votes |
public void onCapabilityChanged(CapabilityInfo capabilityInfo) { Log.d(TAG, "onCapabilityChanged(): " + capabilityInfo); mWearNodeIds = capabilityInfo.getNodes(); }