com.google.android.gms.wearable.Node Java Examples

The following examples show how to use com.google.android.gms.wearable.Node. 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: SendByteArrayToNode.java    From ExceptionWear with Apache License 2.0 6 votes vote down vote up
public void run() {
    if ((objectArray.length / 1024) > 100) {
        throw new RuntimeException("Object is too big to push it via Google Play Services");
    }
    GoogleApiClient googleApiClient = SendWearManager.getInstance(context);
    googleApiClient.blockingConnect(WearExceptionTools.CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
    for (Node node : nodes.getNodes()) {
        MessageApi.SendMessageResult result;
        result = Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WearExceptionTools.MESSAGE_EXCEPTION_PATH, objectArray).await();

        if (!result.getStatus().isSuccess()) {
            Log.v(WearExceptionTools.EXCEPTION_WEAR_TAG, "ERROR: failed to send Message via Google Play Services");
        }
    }
}
 
Example #2
Source File: MainActivity.java    From wear-os-samples with Apache License 2.0 6 votes vote down vote up
private void showDiscoveredNodes(Set<Node> nodes) {
    List<String> nodesList = new ArrayList<>();
    for (Node node : nodes) {
        nodesList.add(node.getDisplayName());
    }
    Log.d(
            TAG,
            "Connected Nodes: "
                    + (nodesList.isEmpty()
                            ? "No connected device was found for the given capabilities"
                            : TextUtils.join(",", nodesList)));
    String msg;
    if (!nodesList.isEmpty()) {
        msg = getString(R.string.connected_nodes, TextUtils.join(", ", nodesList));
    } else {
        msg = getString(R.string.no_device);
    }
    Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show();
}
 
Example #3
Source File: IncomingRequestWearService.java    From wear-os-samples with Apache License 2.0 6 votes vote down vote up
private String pickBestNodeId(Set<Node> nodes) {

        Log.d(TAG, "pickBestNodeId: " + nodes);


        String bestNodeId = null;
        /* Find a nearby node or pick one arbitrarily. There should be only one phone connected
         * that supports this sample.
         */
        for (Node node : nodes) {
            if (node.isNearby()) {
                return node.getId();
            }
            bestNodeId = node.getId();
        }
        return bestNodeId;
    }
 
Example #4
Source File: WearableApi.java    From LibreAlarm with GNU General Public License v3.0 6 votes vote down vote up
public static void sendMessage(final GoogleApiClient client, final String command,
        final byte[] message, final ResultCallback<MessageApi.SendMessageResult> listener) {
    new Thread(new Runnable() {
        @Override
        public void run() {
            NodeApi.GetConnectedNodesResult nodes =
                    Wearable.NodeApi.getConnectedNodes( client ).await();
            for(Node node : nodes.getNodes()) {
                Log.i(TAG, "sending to " + node.getId() + ", command: " + command);
                PendingResult<MessageApi.SendMessageResult> pR =
                        Wearable.MessageApi.sendMessage(client, node.getId(), command, message);
                if (listener != null) pR.setResultCallback(listener);
            }
        }
    }).start();
}
 
Example #5
Source File: ActionReceiver.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Sends the given message to the handheld.
 * @param path message path
 * @param message the message
 */
private void sendMessageToHandheld(final @NonNull Context context, final @NonNull String path, final @NonNull String message) {
	new Thread(() -> {
		final GoogleApiClient client = new GoogleApiClient.Builder(context)
				.addApi(Wearable.API)
				.build();
		client.blockingConnect();

		final NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(client).await();
		for(Node node : nodes.getNodes()) {
			final MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(client, node.getId(), path, message.getBytes()).await();
			if (!result.getStatus().isSuccess()){
				Log.w(TAG, "Failed to send " + path + " to " + node.getDisplayName());
			}
		}
		client.disconnect();
	}).start();
}
 
Example #6
Source File: SendToDataLayerThread.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Void doInBackground(DataMap... params) {
    NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
    for (Node node : nodes.getNodes()) {
        for (DataMap dataMap : params) {
            PutDataMapRequest putDMR = PutDataMapRequest.create(path);
            putDMR.getDataMap().putAll(dataMap);
            PutDataRequest request = putDMR.asPutDataRequest();
            DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleApiClient,request).await();
            if (result.getStatus().isSuccess()) {
                Log.d("SendDataThread", "DataMap: " + dataMap + " sent to: " + node.getDisplayName());
            } else {
                Log.d("SendDataThread", "ERROR: failed to send DataMap");
            }
        }
    }

    return null;
}
 
Example #7
Source File: WearDataLayerListenerService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static void sendMessageToWatch(final String path, final byte[] data, String capability){
	Wearable.getCapabilityClient(ApplicationLoader.applicationContext)
			.getCapability(capability, CapabilityClient.FILTER_REACHABLE)
			.addOnCompleteListener(new OnCompleteListener<CapabilityInfo>(){
				@Override
				public void onComplete(@NonNull Task<CapabilityInfo> task){
					CapabilityInfo info=task.getResult();
					if(info!=null){
						MessageClient mc=Wearable.getMessageClient(ApplicationLoader.applicationContext);
						Set<Node> nodes=info.getNodes();
						for(Node node:nodes){
							mc.sendMessage(node.getId(), path, data);
						}
					}
				}
			});
}
 
Example #8
Source File: MainActivity.java    From rnd-android-wear-tesla with MIT License 6 votes vote down vote up
private void retrieveWearableDeviceNode() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (mGoogleApiClient != null && !(mGoogleApiClient.isConnected() || mGoogleApiClient.isConnecting()))
                mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);

            NodeApi.GetConnectedNodesResult result =
                    Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();

            List<Node> nodes = result.getNodes();

            if (nodes.size() > 0)
                mNodeId = nodes.get(0).getId();

            Log.v(TAG, "Node ID of watch: " + mNodeId);

            mGoogleApiClient.disconnect();
        }
    }).start();
}
 
Example #9
Source File: SendToDataLayerThread.java    From NightWatch with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Void doInBackground(DataMap... params) {
    NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await();
    for (Node node : nodes.getNodes()) {
        for (DataMap dataMap : params) {
            PutDataMapRequest putDMR = PutDataMapRequest.create(path);
            putDMR.getDataMap().putAll(dataMap);
            PutDataRequest request = putDMR.asPutDataRequest();
            DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleApiClient,request).await();
            if (result.getStatus().isSuccess()) {
                Log.d("SendDataThread", "DataMap: " + dataMap + " sent to: " + node.getDisplayName());
            } else {
                Log.d("SendDataThread", "ERROR: failed to send DataMap");
            }
        }
    }

    return null;
}
 
Example #10
Source File: LoginActivity.java    From rnd-android-wear-tesla with MIT License 6 votes vote down vote up
private void retrieveWearableDeviceNode() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (mGoogleApiClient != null && !(mGoogleApiClient.isConnected() || mGoogleApiClient.isConnecting()))
                mGoogleApiClient.blockingConnect(1000, TimeUnit.MILLISECONDS);

            NodeApi.GetConnectedNodesResult result =
                    Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();

            List<Node> nodes = result.getNodes();

            if (nodes.size() > 0)
                mNodeId = nodes.get(0).getId();

            Log.v("TAG", "Node ID of watch: " + mNodeId);

            mGoogleApiClient.disconnect();
        }
    }).start();
}
 
Example #11
Source File: MessageReceiverService.java    From ibm-wearables-android-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Handle messages from the phone
 * @param messageEvent new message from the phone
 */
@Override
public void onMessageReceived(MessageEvent messageEvent) {

    if (messageEvent.getPath().equals("/start")) {
        dataManager.turnSensorOn(Integer.valueOf(new String(messageEvent.getData())));
    }

    else if (messageEvent.getPath().equals("/stop")){
        dataManager.turnSensorOff(Integer.valueOf(new String(messageEvent.getData())));
    }

    else if (messageEvent.getPath().equals("/stopAll")){
        dataManager.turnAllSensorsOff();
    }

    else if (messageEvent.getPath().equals("/ping")){
        NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await();
        for(Node node : nodes.getNodes()) {
            Wearable.MessageApi.sendMessage(apiClient, node.getId(), "/connected", null).await();
        }
    }
}
 
Example #12
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onPeerConnected(com.google.android.gms.wearable.Node peer) {//KS onPeerConnected and onPeerDisconnected deprecated at the same time as BIND_LISTENER

    super.onPeerConnected(peer);
    String id = peer.getId();
    String name = peer.getDisplayName();
    Log.d(TAG, "onPeerConnected peer name & ID: " + name + "|" + id);
    sendPrefSettings();
    if (mPrefs.getBoolean("enable_wearG5", false)) {//watch_integration
        Log.d(TAG, "onPeerConnected call initWearData for node=" + peer.getDisplayName());
        initWearData();
        //Only stop service if Phone will rely on Wear Collection Service
        if (mPrefs.getBoolean("force_wearG5", false)) {
            Log.d(TAG, "onPeerConnected force_wearG5=true Phone stopBtService and continue to use Wear G5 BT Collector");
            stopBtService();
        } else {
            Log.d(TAG, "onPeerConnected onPeerConnected force_wearG5=false Phone startBtService");
            startBtService();
        }
    }
}
 
Example #13
Source File: CommunicationService.java    From rnd-android-wear-tesla with MIT License 6 votes vote down vote up
private void retrieveHandHoldDeviceNode() {
    new Thread(new Runnable() {
        @Override
        public void run() {
            if (mGoogleApiClient != null && !(mGoogleApiClient.isConnected() || mGoogleApiClient.isConnecting()))
                mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);

            NodeApi.GetConnectedNodesResult result =
                    Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();

            List<Node> nodes = result.getNodes();

            if (nodes.size() > 0)
                mNodeId = nodes.get(0).getId();

            Log.v(LOG_TAG, "Node ID of phone: " + mNodeId);

            mGoogleApiClient.disconnect();
        }
    }).start();
}
 
Example #14
Source File: ListenerService.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
private Node updatePhoneSyncBgsCapability(CapabilityInfo capabilityInfo) {
    // Log.d(TAG, "CapabilityInfo: " + capabilityInfo);

    Set<Node> connectedNodes = capabilityInfo.getNodes();
    return pickBestNode(connectedNodes);
    // mPhoneNodeId = pickBestNodeId(connectedNodes);
}
 
Example #15
Source File: WearService.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
public static WearService getInstance(final Node node, final WearManager mgr) {
    String nodeId = node.getId();
    String[] serviceId = nodeId.split("-");

    WearService service = new WearService(WearUtils.createServiceId(nodeId));
    service.setName(WearConst.DEVICE_NAME + "(" + serviceId[0] + ")");
    service.setNetworkType(NetworkType.BLE);
    service.addProfile(new WearCanvasProfile(mgr));
    service.addProfile(new WearDeviceOrientationProfile(mgr));
    service.addProfile(new WearKeyEventProfile(mgr));
    service.addProfile(new WearNotificationProfile());
    service.addProfile(new WearTouchProfile(mgr));
    service.addProfile(new WearVibrationProfile());
    return service;
}
 
Example #16
Source File: MyActivity.java    From flopsydroid with Apache License 2.0 5 votes vote down vote up
private void getNodes(final OnGotNodesListener cb) {
    Wearable.NodeApi.getConnectedNodes(getGoogleApiClient()).setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
        @Override
        public void onResult(NodeApi.GetConnectedNodesResult nodes) {
            ArrayList<String> results= new ArrayList<String>();

            for (Node node : nodes.getNodes()) {
                if(!results.contains(node.getId())) results.add(node.getId());
            }

            cb.onGotNodes(results);
        }
    });
}
 
Example #17
Source File: WearMessenger.java    From watchpresenter with Apache License 2.0 5 votes vote down vote up
private Collection<String> getNodes() {
    HashSet<String> results = new HashSet<String>();
    NodeApi.GetConnectedNodesResult nodes =
            Wearable.NodeApi.getConnectedNodes(gApiClient).await();
    for (Node node : nodes.getNodes()) {
        results.add(node.getId());
    }
    Log.d(Constants.LOG_TAG, "Got " + results.size() + " nodes");
    return results;
}
 
Example #18
Source File: SensorSelectionDialogFragment.java    From Sensor-Data-Logger with Apache License 2.0 5 votes vote down vote up
public void setAvailableNodes(List<Node> nodes) {
    availableNodes = new HashMap<>();
    for (Node node : nodes) {
        if (node == null) {
            continue;
        }
        availableNodes.put(node.getId(), node);
    }
}
 
Example #19
Source File: SensorSelectionDialogFragment.java    From Sensor-Data-Logger with Apache License 2.0 5 votes vote down vote up
/**
 * Calls @requestAvailableSensors for all connected nearby nodes
 * in order to pre-fetch the available sensors for the dialog.
 */
private void requestAvailableSensors() {
    Log.d(TAG, "Pre-fetching available sensors from all nearby nodes");
    for (Node node : app.getGoogleApiMessenger().getLastConnectedNearbyNodes()) {
        if (!hasSelectedSensorsForNode(node.getId())) {
            requestAvailableSensors(node.getId(), new AvailableSensorsUpdatedListener() {
                @Override
                public void onAvailableSensorsUpdated(String nodeId, List<DeviceSensor> deviceSensors) {
                    Log.d(TAG, "Fetched available sensors on " + nodeId);
                    availableSensors.put(nodeId, deviceSensors);
                }
            });
        }
    }
}
 
Example #20
Source File: WearMessageListenerService.java    From AnkiDroid-Wear with GNU General Public License v2.0 5 votes vote down vote up
private void fireMessage(final byte[] data, final String path,final int retryCount) {

        PendingResult<NodeApi.GetConnectedNodesResult> nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient);
        nodes.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() {
            @Override
            public void onResult(NodeApi.GetConnectedNodesResult result) {
                for (int i = 0; i < result.getNodes().size(); i++) {
                    Node node = result.getNodes().get(i);
                    Log.v(TAG, "Phone firing message with path : " + path);

                    PendingResult<MessageApi.SendMessageResult> messageResult = Wearable.MessageApi.sendMessage(googleApiClient, node.getId(),
                            path, data);
                    messageResult.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
                        @Override
                        public void onResult(MessageApi.SendMessageResult sendMessageResult) {
                            Status status = sendMessageResult.getStatus();
                            Timber.d("Status: " + status.toString());
                            if (status.getStatusCode() != WearableStatusCodes.SUCCESS) {
                                if(!status.isSuccess()) {
                                    if (retryCount > 5) return;
                                    soundThreadHandler.postDelayed(new Runnable() {
                                        @Override
                                        public void run() {
                                            fireMessage(data, path, retryCount + 1);
                                        }
                                    }, 1000 * retryCount);
                                }
                            }
                            if (path.equals(CommonIdentifiers.P2W_CHANGE_SETTINGS)) {
                                Intent messageIntent = new Intent();
                                messageIntent.setAction(Intent.ACTION_SEND);
                                messageIntent.putExtra("status", status.getStatusCode());
                                LocalBroadcastManager.getInstance(WearMessageListenerService.this).sendBroadcast(messageIntent);
                            }
                        }
                    });
                }
            }
        });
    }
 
Example #21
Source File: GoogleApiMessenger.java    From Sensor-Data-Logger with Apache License 2.0 5 votes vote down vote up
public boolean disconnect() {
    Log.d(TAG, "Disconnecting Google API client");
    status.setLastConnectedNodes(new ArrayList<Node>());
    if (googleApiClient != null && googleApiClient.isConnected()) {
        googleApiClient.disconnect();
        return true;
    }
    return false;
}
 
Example #22
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void sendMessagePayload(Node node, String pathdesc, final String path, byte[] payload) {
    Log.d(TAG, "Benchmark: doInBackground sendMessagePayload " + pathdesc + "=" + path + " nodeID=" + node.getId() + " nodeName=" + node.getDisplayName() + ((payload != null) ? (" payload.length=" + payload.length) : ""));

    //ORIGINAL ASYNC METHOD
    PendingResult<MessageApi.SendMessageResult> result = Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), path, payload);
    result.setResultCallback(new ResultCallback<MessageApi.SendMessageResult>() {
        @Override
        public void onResult(MessageApi.SendMessageResult sendMessageResult) {
            if (!sendMessageResult.getStatus().isSuccess()) {
                Log.e(TAG, "sendMessagePayload ERROR: failed to send request " + path + " Status=" + sendMessageResult.getStatus().getStatusMessage());
            } else {
                Log.d(TAG, "sendMessagePayload Sent request " + node.getDisplayName() + " " + path + " Status=: " + sendMessageResult.getStatus().getStatusMessage());
            }
        }
    });

    //TEST**************************************************************************
    DataMap datamap;
    if (bBenchmarkBgs && path.equals(SYNC_BGS_PATH)) {
        //bBenchmarkBgs = runBenchmarkTest(node, pathdesc+"_BM", path+"_BM", payload, bBenchmarkDup);
        datamap = getWearTransmitterData(1000, 0, 0);//generate 1000 records of test data
        if (datamap != null) {
            bBenchmarkBgs = runBenchmarkTest(node, pathdesc + "_BM", path + "_BM", datamap.toByteArray(), false);
        }
    } else if (bBenchmarkLogs && path.equals(SYNC_LOGS_PATH)) {
        //bBenchmarkLogs = runBenchmarkTest(node, pathdesc+"_BM", path+"_BM", payload, bBenchmarkDup);
        datamap = getWearLogData(1000, 0, 0, -1);//generate 1000 records of test data
        if (datamap != null) {
            bBenchmarkLogs = runBenchmarkTest(node, pathdesc + "_BM", path + "_BM", datamap.toByteArray(), false);
        }
    }
    //Random Test
    if (bBenchmarkRandom) {
        final byte[] randomBytes = new byte[200000];
        ThreadLocalRandom.current().nextBytes(randomBytes);
        bBenchmarkRandom = runBenchmarkTest(node, pathdesc + "_BM_RAND", path + "_BM_RAND", randomBytes, false);
        Log.i(TAG, "Benchmark: DONE!");
    }
    //******************************************************************************
}
 
Example #23
Source File: WearDataLayerListenerService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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 #24
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void setLocalNodeName() {
    forceGoogleApiConnect();
    NodeApi.GetLocalNodeResult localnodes = Wearable.NodeApi.getLocalNode(googleApiClient).await(60, TimeUnit.SECONDS);
    Node getnode = localnodes.getNode();
    localnode = getnode != null ? getnode.getDisplayName() + "|" + getnode.getId() : "";
    UserError.Log.d(TAG, "setLocalNodeName.  localnode=" + localnode);
}
 
Example #25
Source File: WatchUpdaterService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPeerDisconnected(com.google.android.gms.wearable.Node peer) {//KS onPeerConnected and onPeerDisconnected deprecated at the same time as BIND_LISTENER
    super.onPeerDisconnected(peer);
    String id = peer.getId();
    String name = peer.getDisplayName();
    Log.d(TAG, "onPeerDisconnected peer name & ID: " + name + "|" + id);
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    if (sharedPrefs.getBoolean("watch_integration", false)) {
        Log.d(TAG, "onPeerDisconnected watch_integration=true Phone startBtService");
        startBtService();
    }
}
 
Example #26
Source File: MainActivity.java    From wearable with Apache License 2.0 5 votes vote down vote up
public void run() {
    NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleClient).await();
    for (Node node : nodes.getNodes()) {
        MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(googleClient, node.getId(), path, message.getBytes()).await();
        if (result.getStatus().isSuccess()) {
            Log.v(TAG, "SendThread: message send to " + node.getDisplayName());

        } else {
            // Log an error
            Log.v(TAG, "SendThread: message failed to" + node.getDisplayName());
        }
    }
}
 
Example #27
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private String pickBestNodeId(Set<Node> nodes) {//TODO remove once confirm not needed
    String bestNodeId = null;
    // Find a nearby node or pick one arbitrarily
    for (Node node : nodes) {
        if (node.isNearby()) {
            return node.getId();
        }
        bestNodeId = node.getId();
    }
    return bestNodeId;
}
 
Example #28
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onPeerConnected(Node peer) {//Deprecated with BIND_LISTENER
    super.onPeerConnected(peer);
    String id = peer.getId();
    String name = peer.getDisplayName();
    Log.d(TAG, "onPeerConnected peer name & ID: " + name + "|" + id);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sendPrefSettings();
    if (mPrefs.getBoolean("enable_wearG5", false) && !mPrefs.getBoolean("force_wearG5", false)) {
        stopBtService();
        ListenerService.requestData(this);
    }
}
 
Example #29
Source File: ListenerService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
AsyncBenchmarkTester(Context context, Node thisnode, String thispathdesc, String thispath, byte[] thispayload, boolean thisbduplicate) {
    node = thisnode;
    pathdesc = thispathdesc;
    path = thispath;
    payload = thispayload;
    bDuplicate = thisbduplicate;
    Log.d(TAG, "AsyncBenchmarkTester: " + thispath);
}
 
Example #30
Source File: WearDataLayerListenerService.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static void sendMessageToWatch(final String path, final byte[] data, String capability) {
	Wearable.getCapabilityClient(ApplicationLoader.applicationContext)
			.getCapability(capability, CapabilityClient.FILTER_REACHABLE)
			.addOnCompleteListener(task -> {
				CapabilityInfo info = task.getResult();
				if (info != null) {
					MessageClient mc = Wearable.getMessageClient(ApplicationLoader.applicationContext);
					Set<Node> nodes = info.getNodes();
					for (Node node : nodes) {
						mc.sendMessage(node.getId(), path, data);
					}
				}
			});
}