com.google.android.gms.wearable.DataApi Java Examples
The following examples show how to use
com.google.android.gms.wearable.DataApi.
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: SendToDataLayerThread.java From xDrip-Experimental with GNU General Public License v3.0 | 6 votes |
@Override protected Void doInBackground(DataMap... params) { try { final NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await(15, TimeUnit.SECONDS); 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(15, TimeUnit.SECONDS); if (result.getStatus().isSuccess()) { Log.d(TAG, "DataMap: " + dataMap + " sent to: " + node.getDisplayName()); } else { Log.d(TAG, "ERROR: failed to send DataMap"); } } } } catch (Exception e) { Log.e(TAG, "Got exception sending data to wear: " + e.toString()); } return null; }
Example #2
Source File: MainActivity.java From WearOngoingNotificationSample with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void sendMessage() { if (mGoogleApiClient.isConnected()) { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(Constants.PATH_NOTIFICATION); // Add data to the request putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, String.format("hello world! %d", count++)); Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Asset asset = createAssetFromBitmap(icon); putDataMapRequest.getDataMap().putAsset(Constants.KEY_IMAGE, asset); PutDataRequest request = putDataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { Log.d(TAG, "putDataItem status: " + dataItemResult.getStatus().toString()); } }); } }
Example #3
Source File: SendToDataLayerThread.java From NightWatch with GNU General Public License v3.0 | 6 votes |
@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 #4
Source File: TrackActivity.java From android-samples with Apache License 2.0 | 6 votes |
/** * Send the current status of the step count tracking weather it is running or not. This message * is important and we should have guarantee of delivery to maintain the state of tracking status * on the phone. That is why we are using DataMap to communicate. So, if the phone is not connected * the message won't get lost. As soon as the phone connects, this status message will pass to the * phone application. * * @param isTracking true if the tracking is running */ private void sendTrackingStatusDataMap(boolean isTracking) { PutDataMapRequest dataMapRequest = PutDataMapRequest.create(STEP_TRACKING_STATUS_PATH); dataMapRequest.getDataMap().putBoolean("status", isTracking); dataMapRequest.getDataMap().putLong("status-time", System.currentTimeMillis()); PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, putDataRequest) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(@NonNull DataApi.DataItemResult dataItemResult) { //check if the message is delivered? //If the status is failed, that means that the currently device is //not connected. The data will get deliver when phone gets connected to the watch. Log.d("Data saving", dataItemResult.getStatus().isSuccess() ? "Success" : "Failed"); } }); }
Example #5
Source File: MainActivity.java From android-Quiz with Apache License 2.0 | 6 votes |
@Override protected void onStop() { Wearable.DataApi.removeListener(mGoogleApiClient, this); Wearable.MessageApi.removeListener(mGoogleApiClient, this); // Tell the wearable to end the quiz (counting unanswered questions as skipped), and then // disconnect mGoogleApiClient. DataMap dataMap = new DataMap(); dataMap.putInt(NUM_CORRECT, mNumCorrect); dataMap.putInt(NUM_INCORRECT, mNumIncorrect); if (mHasQuestionBeenAsked) { mNumSkipped += 1; } mNumSkipped += mFutureQuestions.size(); dataMap.putInt(NUM_SKIPPED, mNumSkipped); if (mNumCorrect + mNumIncorrect + mNumSkipped > 0) { sendMessageToWearable(QUIZ_EXITED_PATH, dataMap.toByteArray()); } clearQuizStatus(); super.onStop(); }
Example #6
Source File: DigitalWatchFaceUtil.java From wear-os-samples with Apache License 2.0 | 6 votes |
/** * Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}. * If the config DataItem doesn't exist, it's created. */ public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig, final Callable<Void> callable) { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE); putDataMapRequest.setUrgent(); DataMap configToPut = putDataMapRequest.getDataMap(); configToPut.putAll(newConfig); Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest()) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { try{ if (callable != null) { callable.call(); } } catch (Exception e) { Log.e(TAG, "Finish callback failed.", e); } if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus()); } } }); }
Example #7
Source File: SunsetsWatchFaceUtil.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
public static void fetchConfigDataMap(final GoogleApiClient client, final FetchConfigDataMapCallback callback) { Wearable.NodeApi.getLocalNode(client).setResultCallback( new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { String localNode = getLocalNodeResult.getNode().getId(); Uri uri = new Uri.Builder() .scheme("wear") .path(SunsetsWatchFaceUtil.PATH_WITH_FEATURE) .authority(localNode) .build(); Wearable.DataApi.getDataItem(client, uri) .setResultCallback(new DataItemResultCallback(callback)); } } ); }
Example #8
Source File: SendToDataLayerThread.java From NightWatch with GNU General Public License v3.0 | 6 votes |
@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 #9
Source File: SunsetsWatchFaceUtil.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
/** * Asynchronously fetches the current config {@link DataMap} for {@link SunsetsWatchFace} * and passes it to the given callback. * <p> * If the current config {@link DataItem} doesn't exist, it isn't created and the callback * receives an empty DataMap. */ public static void fetchConfigDataMap(final GoogleApiClient client, final FetchConfigDataMapCallback callback) { Wearable.NodeApi.getLocalNode(client).setResultCallback( new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { String localNode = getLocalNodeResult.getNode().getId(); Uri uri = new Uri.Builder() .scheme("wear") .path(SunsetsWatchFaceUtil.PATH_WITH_FEATURE) .authority(localNode) .build(); Wearable.DataApi.getDataItem(client, uri) .setResultCallback(new DataItemResultCallback(callback)); } } ); }
Example #10
Source File: UARTConfigurationsActivity.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * This method read the UART configurations from the DataApi and populates the adapter with them. */ private void populateConfigurations() { if (googleApiClient.isConnected()) { final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(googleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX); results.setResultCallback(dataItems -> { final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount()); for (int i = 0; i < dataItems.getCount(); ++i) { final DataItem item = dataItems.get(i); final long id = ContentUris.parseId(item.getUri()); final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); final UartConfiguration configuration = new UartConfiguration(dataMap, id); configurations.add(configuration); } adapter.setConfigurations(configurations); dataItems.release(); }); } }
Example #11
Source File: SynchronizedNotificationsFragment.java From android-SynchronizedNotifications with Apache License 2.0 | 6 votes |
/** * Builds a DataItem that on the wearable will be interpreted as a request to show a * notification. The result will be a notification that only shows up on the wearable. */ private void buildWearableOnlyNotification(String title, String content, String path) { if (mGoogleApiClient.isConnected()) { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path); putDataMapRequest.getDataMap().putString(Constants.KEY_CONTENT, content); putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, title); PutDataRequest request = putDataMapRequest.asPutDataRequest(); request.setUrgent(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { Log.e(TAG, "buildWatchOnlyNotification(): Failed to set the data, " + "status: " + dataItemResult.getStatus().getStatusCode()); } } }); } else { Log.e(TAG, "buildWearableOnlyNotification(): no Google API Client connection"); } }
Example #12
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override //OnConnectionFailedListener public void onConnectionFailed(ConnectionResult result) { if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution()) { try { mResolvingError = true; result.startResolutionForResult(this, REQUEST_RESOLVE_ERROR); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mGoogleApiClient.connect(); } } else { Log.e(TAG, "Connection to Google API client has failed"); mResolvingError = false; mStartActivityBtn.setEnabled(false); mSendPhotoBtn.setEnabled(false); Wearable.DataApi.removeListener(mGoogleApiClient, this); Wearable.MessageApi.removeListener(mGoogleApiClient, this); Wearable.NodeApi.removeListener(mGoogleApiClient, this); } }
Example #13
Source File: RemoteSensorManager.java From SensorDashboard with Apache License 2.0 | 6 votes |
private void filterBySensorIdInBackground(final int sensorId) { Log.d(TAG, "filterBySensorId(" + sensorId + ")"); if (validateConnection()) { PutDataMapRequest dataMap = PutDataMapRequest.create("/filter"); dataMap.getDataMap().putInt(DataMapKeys.FILTER, sensorId); dataMap.getDataMap().putLong(DataMapKeys.TIMESTAMP, System.currentTimeMillis()); PutDataRequest putDataRequest = dataMap.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { Log.d(TAG, "Filter by sensor " + sensorId + ": " + dataItemResult.getStatus().isSuccess()); } }); } }
Example #14
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override public void run() { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH); putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++); PutDataRequest request = putDataMapRequest.asPutDataRequest(); LOGD(TAG, "Generating DataItem: " + request); if (!mGoogleApiClient.isConnected()) { return; } Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { Log.e(TAG, "ERROR: failed to putDataItem, status code: " + dataItemResult.getStatus().getStatusCode()); } } }); }
Example #15
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
public void onDeleteEventsClicked(View v) { if (mGoogleApiClient.isConnected()) { Wearable.DataApi.getDataItems(mGoogleApiClient) .setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(DataItemBuffer result) { if (result.getStatus().isSuccess()) { deleteDataItems(result); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onDeleteEventsClicked(): failed to get Data Items"); } } result.close(); } }); } else { Log.e(TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services"); } }
Example #16
Source File: DaVinci.java From DaVinci with Apache License 2.0 | 6 votes |
public Bitmap getBitmapFromDataApi(String path) { final Uri uri = getUriForDataItem(path); Log.d(TAG, "Load bitmap " + path + " " + uri.toString()); if (uri != null) { final DataApi.DataItemResult result = Wearable.DataApi.getDataItem(mApiClient, uri).await(); if (result != null && result.getDataItem() != null) { Log.d(TAG, "From DataApi"); final DataMapItem dataMapItem = DataMapItem.fromDataItem(result.getDataItem()); final Asset firstAsset = dataMapItem.getDataMap().getAsset(imageAssetName); if (firstAsset != null) { Bitmap bitmap = loadBitmapFromAsset(firstAsset); return bitmap; } } } Log.d(TAG, "can't find " + path + " [" + imageAssetName + "] in DataApi"); return null; }
Example #17
Source File: WatchServices.java From WearPay with GNU General Public License v2.0 | 6 votes |
@DebugLog private void sendToWatch(String code) { Bitmap bitmapQR = EncodingHandlerUtils.createQRCode(code, 600); Bitmap bitmapBar = EncodingHandlerUtils.createBarcode(code, 600, 200); PutDataMapRequest dataMap = PutDataMapRequest.create(Common.PATH_QR_CODE); dataMap.getDataMap().putAsset(Common.KEY_QR_CODE, toAsset(bitmapQR)); dataMap.getDataMap().putAsset(Common.KEY_BAR_CODE, toAsset(bitmapBar)); PutDataRequest request = dataMap.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override @DebugLog public void onResult(DataApi.DataItemResult dataItemResult) { if (dataItemResult.getStatus().isSuccess()) { System.out.println("发送成功"); } else { System.out.println("发送失败"); } } }); //sendMessageToAllNodes(Common.PATH_CODE, code.getBytes()); }
Example #18
Source File: MainActivity.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onConnected(Bundle bundle) { Wearable.DataApi.addListener(mGoogleApiClient, this); if (mDrone != null) { Message.sendActionTypeMessage(mDrone.getCurrentAction(), mGoogleApiClient); } sendInteractionType(); // launch the app on the wear Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).setResultCallback( new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(@NonNull NodeApi.GetConnectedNodesResult getConnectedNodesResult) { for (Node node : getConnectedNodesResult.getNodes()) { Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), Message.OPEN_ACTIVITY_MESSAGE, new byte[0]); } } }); }
Example #19
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
/** * Asks the next enqueued question if it exists, otherwise ends the quiz. */ private void askNextQuestionIfExists() { if (mFutureQuestions.isEmpty()) { // Quiz has been completed - send message to wearable to display end report. DataMap dataMap = new DataMap(); dataMap.putInt(NUM_CORRECT, mNumCorrect); dataMap.putInt(NUM_INCORRECT, mNumIncorrect); dataMap.putInt(NUM_SKIPPED, mNumSkipped); sendMessageToWearable(QUIZ_ENDED_PATH, dataMap.toByteArray()); setHasQuestionBeenAsked(false); } else { // Ask next question by putting a DataItem that will be received on the wearable. Wearable.DataApi.putDataItem(mGoogleApiClient, mFutureQuestions.remove().toPutDataRequest()); setHasQuestionBeenAsked(true); } }
Example #20
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
/** * Sends the asset that was created form the photo we took by adding it to the Data Item store. */ private void sendPhoto(Asset asset) { PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH); dataMap.getDataMap().putAsset(IMAGE_KEY, asset); dataMap.getDataMap().putLong("time", new Date().getTime()); PutDataRequest request = dataMap.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { LOGD(TAG, "Sending image was successful: " + dataItemResult.getStatus() .isSuccess()); } }); }
Example #21
Source File: WearService.java From LibreAlarm with GNU General Public License v3.0 | 6 votes |
@Override public void onConnectionFailed(ConnectionResult result) { if (mResolvingError) { // Already attempting to resolve an error. return; } else if (result.hasResolution() && mActivity != null) { try { mResolvingError = true; result.startResolutionForResult(mActivity, 1000); } catch (IntentSender.SendIntentException e) { // There was an error with the resolution intent. Try again. mGoogleApiClient.connect(); } } else { Log.e(TAG, "Connection to Google API client has failed"); mResolvingError = false; if (mListener != null) mListener.onDataUpdated(); Wearable.MessageApi.removeListener(mGoogleApiClient, this); Wearable.DataApi.removeListener(mGoogleApiClient, this); } }
Example #22
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 6 votes |
private void sendDataMapRequest(PutDataMapRequest request) { Wearable.DataApi.putDataItem(mApiClient, request.asPutDataRequest()).setResultCallback( new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (dataItemResult.getStatus().isSuccess()) { if (ENABLE_LOG) Log.d(TAG, "sent"); } else { if (ENABLE_LOG) Log.d(TAG, "send error"); } } } ); }
Example #23
Source File: MainActivity.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void onConnected(Bundle bundle) { Wearable.DataApi.addListener(mGoogleApiClient, this); // get existing data PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient); results.setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(@NonNull DataItemBuffer dataItems) { for (DataItem dataItem : dataItems) { switch (Message.getMessageType(dataItem)) { case ACTION_TYPE: int productAction = Message.decodeActionTypeMessage(dataItem); onActionTypeChanged(productAction); break; case INTERACTION_TYPE: int interactionType = Message.decodeInteractionTypeMessage(dataItem); onInteractionTypeChanged(interactionType); break; } } dataItems.release(); } }); }
Example #24
Source File: WearService.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
public void run() { GoogleApiClient googleApiClient = new GoogleApiClient.Builder(context) .addApi(Wearable.API) .build(); ConnectionResult connectionResult = googleApiClient.blockingConnect( Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.SECONDS); if (!connectionResult.isSuccess() || !googleApiClient.isConnected()) { Log.e("ETSMobile-Wear", connectionResult.getErrorMessage()); return; } PutDataMapRequest dataMapReq = PutDataMapRequest.create(path); ArrayList<DataMap> dataMapArrayList = new ArrayList<>(); for (Seances seance : seances) { dataMapArrayList.add(seance.putData()); } dataMapReq.getDataMap().putDataMapArrayList("list_seances", dataMapArrayList); PutDataRequest request = dataMapReq.asPutDataRequest(); DataApi.DataItemResult dataItemResult = Wearable .DataApi .putDataItem(googleApiClient, request) .await(); if (dataItemResult.getStatus().isSuccess()) { if (BuildConfig.DEBUG) Log.d("SendToDataLayerThread", "Data sent successfully!!"); } else { // Log an error if (BuildConfig.DEBUG) Log.d("SendToDataLayerThread", "ERROR: failed to send Message"); } }
Example #25
Source File: SunsetsWatchFaceUtil.java From american-sunsets-watch-face with Apache License 2.0 | 5 votes |
/** * Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}. * If the config DataItem doesn't exist, it's created. */ public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig) { PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE); DataMap configToPut = putDataMapRequest.getDataMap(); configToPut.putAll(newConfig); Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest()) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus()); } } }); }
Example #26
Source File: MainActivity.java From android-Quiz with Apache License 2.0 | 5 votes |
private void resetDataItems(DataItemBuffer dataItemList) { if (mGoogleApiClient.isConnected()) { for (final DataItem dataItem : dataItemList) { final Uri dataItemUri = dataItem.getUri(); Wearable.DataApi.getDataItem(mGoogleApiClient, dataItemUri) .setResultCallback(new ResetDataItemCallback()); } } else { Log.e(TAG, "Failed to reset data items because client is disconnected from " + "Google Play Services"); } }
Example #27
Source File: Message.java From DronesWear with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static PendingResult<DataApi.DataItemResult> sendInteractionTypeMessage(int interactionBitfield, GoogleApiClient googleApiClient) { PutDataMapRequest dataMapRequest = PutDataMapRequest.create(INTERACTION_TYPE_PATH); DataMap dataMap = dataMapRequest.getDataMap(); //Data set dataMap.putInt(VALUE_STR, interactionBitfield); // Data Push PutDataRequest request = dataMapRequest.asPutDataRequest(); PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(googleApiClient, request); return pendingResult; }
Example #28
Source File: DismissListener.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override // ConnectionCallbacks public void onConnected(Bundle bundle) { final Uri dataItemUri = new Uri.Builder().scheme(WEAR_URI_SCHEME).path(Constants.BOTH_PATH).build(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Deleting Uri: " + dataItemUri.toString()); } Wearable.DataApi.deleteDataItems( mGoogleApiClient, dataItemUri).setResultCallback(this); }
Example #29
Source File: WearService.java From WearPay with GNU General Public License v2.0 | 5 votes |
/** * Extracts {@link android.graphics.Bitmap} data from the * {@link com.google.android.gms.wearable.Asset} */ protected Bitmap loadBitmapFromAsset(Asset asset) { if (asset == null) { throw new IllegalArgumentException("Asset must be non-null"); } InputStream assetInputStream = Wearable.DataApi.getFdForAsset( mGoogleApiClient, asset).await().getInputStream(); if (assetInputStream == null) { return null; } return BitmapFactory.decodeStream(assetInputStream); }
Example #30
Source File: DismissListener.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override // ResultCallback<DataApi.DeleteDataItemsResult> public void onResult(DataApi.DeleteDataItemsResult deleteDataItemsResult) { if (!deleteDataItemsResult.getStatus().isSuccess()) { Log.e(TAG, "dismissWearableNotification(): failed to delete DataItem"); } mGoogleApiClient.disconnect(); }