@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(LOG_TAG, " in data changed"); for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo(WEATHER_PATH) == 0) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); weather_id = dataMap.getInt(WEATHER_ID); high_temp = dataMap.getDouble(HIGH_TEMP); low_temp = dataMap.getDouble(LOW_TEMP); } } else if (event.getType() == DataEvent.TYPE_DELETED) { // DataItem deleted } } invalidate(); }
/** * This method read the UART configurations from the DataApi and populates the adapter with them. */ private void populateConfigurations() { if (mGoogleApiClient.isConnected()) { final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX); results.setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(final DataItemBuffer 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); } mAdapter.setConfigurations(configurations); dataItems.release(); } }); } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { super.onDataChanged(dataEvents); for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo("/SHAKEINTENSITY") == 0) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); Log.e("Data Event", "value->"+dataMap.getString(SHAKE_INTENSITY_KEY)); LocalStoreUtils.setShakeIntensity(dataMap.getString(SHAKE_INTENSITY_KEY), this); } } } }
@Override // DataApi.DataListener public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "Data changed"); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals( ConfigurationHelper.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); Log.d(TAG, "Config DataItem updated:" + config); // This can happen from this method more often when phone changes updateUiForConfigDataMap(config); } }
private void processData(DataItem item) { if (START_ACTIVITY_PATH.equals(item.getUri().getPath())) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); if (dataMap.containsKey("max")) { mWatchMaxTemp = dataMap.getString("max"); } if (dataMap.containsKey("min")) { mWatchMinTemp = dataMap.getString("min"); } if (dataMap.containsKey("id")) { int resid=getArtResourceForWeatherCondition(dataMap.getInt("id")); mWatchBitmap= BitmapFactory.decodeResource(getResources(), resid); mWatchBitmap=Bitmap.createScaledBitmap(mWatchBitmap, (int) mTextPaint.getTextSize(), (int)mTextPaint.getTextSize(), false); } mWatchTemp=mWatchMaxTemp+" "+mWatchMinTemp; } }
@Override // DataApi.DataListener public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals( WatchFaceUtil.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); Log.d(TAG, "Config DataItem updated:" + config); updateUiForConfigDataMap(config); } }
@Override // DataApi.DataListener public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG,"onDataChanged "+dataEvents); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals(WatchFaceUtil.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); Log.d(TAG, "Config DataItem updated:" + config); updateUiForConfigDataMap(config); } }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { Log.d(LOG_TAG, "Weather data has been changed!"); for (DataEvent event : dataEventBuffer) { DataItem item = event.getDataItem(); if (WEATHER_DATA_PATH.equals(item.getUri().getPath())) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); double high = dataMap.getDouble(WEATHER_DATA_HIGH); double low = dataMap.getDouble(WEATHER_DATA_LOW); long id = dataMap.getLong(WEATHER_DATA_ID); mWeather = (int) Math.round(high) + "/" + (int) Math.round(low); mWeatherId = (int) id; loadIconForWeatherId(); SharedPreferences preferences = getSharedPreferences(PREFERENCES, MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putString(KEY_WEATHER, mWeather); editor.putInt(KEY_WEATHER_ID, mWeatherId); editor.apply(); } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(LOG_TAG, "onDataChanged" ); for (DataEvent dataEvent : dataEvents) { if (DataEvent.TYPE_CHANGED == dataEvent.getType()) { DataItem dataItem = dataEvent.getDataItem(); DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); String path = dataEvent.getDataItem().getUri().getPath(); if (path.equals(WEATHER_PATH)) { Log.d(LOG_TAG, "/weather id=" + dataMap.getString(KEY_UUID)); SunshineSyncAdapter.syncImmediately(this); } } } }
/** * Called whenever a new message sent by the Wearable. * * @param dataEvents buffer with transmitted data */ @Override public void onDataChanged(DataEventBuffer dataEvents) { Log.i(TAG, "onDataChanged()"); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = dataEvent.getDataItem(); Uri uri = dataItem.getUri(); String path = uri.getPath(); if (path.startsWith("/sensors/")) { if (SmartWatch.getInstance() != null) { SmartWatch.getInstance().unpackSensorData(DataMapItem.fromDataItem(dataItem).getDataMap()); } } } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.i("DEV", "Wear: MainActivity.onDataChangeListener"); for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo("/stayawhile/queue") == 0) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); queueUpdated(dataMap.getString(QUEUE_KEY)); } } else if (event.getType() == DataEvent.TYPE_DELETED) { // DataItem deleted } } }
private void deleteSingleIgcFile(DataItem item) { item.freeze(); DataMapItem dataMapItem = DataMapItem.fromDataItem(item); String filename = dataMapItem.getDataMap().getString(Statics.DATADELETE); File dir = getFilesDir(); File[] subFiles = dir.listFiles(); if (subFiles != null) { for (File file : subFiles) { if (filename.contains(Statics.getUTCdateReverse())) return; if (file.getName().equals(filename)) { if (file.delete()) { if (debugMode) Log.d(TAG, "File " + filename + " is deleted."); Wearable.DataApi.deleteDataItems(mGoogleApiClient, item.getUri()); } else { if (debugMode) Log.d(TAG, "File " + filename + " delete error."); } } } } }
private void getExceptionFromWear(DataItem dataItem) { if (debugMode) Log.d(TAG, "Exception from wear!!!"); dataItem.freeze(); DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); ByteArrayInputStream bis = new ByteArrayInputStream(dataMapItem.getDataMap().getByteArray("exception")); Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItem.getUri()); try { ObjectInputStream ois = new ObjectInputStream(bis); Throwable ex = (Throwable) ois.readObject(); FirebaseCrash.log("board: " + dataMapItem.getDataMap().getString("board")); FirebaseCrash.log("fingerprint: " + dataMapItem.getDataMap().getString("fingerprint")); FirebaseCrash.log("model: " + dataMapItem.getDataMap().getString("model")); FirebaseCrash.log("manufacturer: " + dataMapItem.getDataMap().getString("manufacturer")); FirebaseCrash.log("product: " + dataMapItem.getDataMap().getString("product")); FirebaseCrash.report(ex); } catch (IOException | ClassNotFoundException e) { FirebaseCrash.report(e); if (debugMode) Log.e(TAG, Log.getStackTraceString(e)); } }
private void getAllAvailableDataItems() { PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient); results.setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(@NonNull DataItemBuffer dataItems) { if (dataItems.getCount() != 0) { for (DataItem item : dataItems) { if (item.getUri().getPath().contains(Statics.DATAIGC)) { getStringFromAsset(item); } if (item.getUri().getPath().contains(Statics.DATATHROWABLE)) { getExceptionFromWear(item); } if (item.getUri().getPath().contains(Statics.DATABTFAILED)) { getBTFailed(item); } } } dataItems.release(); } }); }
private void getBTFailed(DataItem dataItem) { dataItem.freeze(); final Uri dataItemUri = dataItem.getUri(); DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); final int reason = dataMapItem.getDataMap().getInt("reason"); if (debugMode) Log.d(TAG, "BT failed on wear, reason: " + reason); switch (reason) { case Statics.MY_BT_FAILED_NO_BT: Toast.makeText(getApplicationContext(), R.string.bt_failed_no_bt, Toast.LENGTH_LONG).show(); break; case Statics.MY_BT_FAILED_NO_DEVICE: Toast.makeText(getApplicationContext(), R.string.bt_failed_no_device, Toast.LENGTH_LONG).show(); break; case Statics.MY_BT_FAILED_USER: Toast.makeText(getApplicationContext(), R.string.bt_failed_user, Toast.LENGTH_LONG).show(); break; } Wearable.DataApi.deleteDataItems(mGoogleApiClient, dataItemUri); prefs.edit().putBoolean(Statics.PREFUSEBTVARIO, false).apply(); checkBoxBT.setChecked(false); }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { for (DataEvent dataEvent : dataEventBuffer) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals( DigitalWatchFaceUtil.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); Log.d("WatchFace", "Config DataItem updated:" + config); updateUiForConfigDataMap(config); } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = event.getDataItem(); 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; } } } }
@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(); } }); }
public static MESSAGE_TYPE getMessageType(DataItem dataItem){ MESSAGE_TYPE messageType = MESSAGE_TYPE.UNKNOWN; if (dataItem != null) { String path = dataItem.getUri().getPath(); if (ACC_PATH.equalsIgnoreCase(path)) { messageType = MESSAGE_TYPE.ACC; } else if (JOYSTICK_PATH.equalsIgnoreCase(path)) { messageType = MESSAGE_TYPE.JOYSTICK; } else if (INTERACTION_TYPE_PATH.equalsIgnoreCase(path)) { messageType = MESSAGE_TYPE.INTERACTION_TYPE; } else if (ACTION_TYPE_PATH.equalsIgnoreCase(path)) { messageType = MESSAGE_TYPE.ACTION_TYPE; } else if (ACTION_PATH.equalsIgnoreCase(path)) { messageType = MESSAGE_TYPE.ACTION; } } return messageType; }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = dataEvent.getDataItem(); Uri uri = dataItem.getUri(); String path = uri.getPath(); if (path.startsWith("/sensors/")) { unpackSensorData( Integer.parseInt(uri.getLastPathSegment()), DataMapItem.fromDataItem(dataItem).getDataMap() ); } } } }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { Log.i("WATCH", "onDataChanged"); for (DataEvent event : dataEventBuffer) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo(DATA_PATH) == 0) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); extractWeatherData(dataMap); } } else if (event.getType() == DataEvent.TYPE_DELETED) { // DataItem deleted } } }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { Log.d(TAG, "onDataChanged"); for (DataEvent event : dataEventBuffer) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed DataItem item = event.getDataItem(); String path = item.getUri().getPath(); Log.d(TAG, "path: " + path); if (path.equals(REQ_PATH)) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); mWeatherId = dataMap.getInt(KEY_WEATHER_ID); mMaxTemperature = dataMap.getDouble(KEY_TEMP_MAX); mMinTemperature = dataMap.getDouble(KEY_TEMP_MIN); mLocation = dataMap.getString(KEY_LOCATION); invalidate(); } } } dataEventBuffer.release(); }
ActiveRequest(DataItem paramDataItem) { this.uri = paramDataItem.getUri(); List localList = this.uri.getPathSegments(); if ((localList != null) && (localList.size() >= 3)) { this.packageName = ((String)localList.get(1)); } for (this.requestId = ((String)localList.get(2));; this.requestId = null) { DataMap localDataMap = DataMap.fromByteArray(paramDataItem.getData()); this.assetId = localDataMap.getString("assetIdentifier"); this.destinationNodes = localDataMap.getStringArray("nodeIds"); if ((this.destinationNodes == null) || (this.destinationNodes.length != 1)) { break; } this.nodeId = this.destinationNodes[0]; return; this.packageName = null; } this.nodeId = null; }
@Override // DataApi.DataListener public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals( SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); Log.d(TAG, "Config DataItem updated:" + config); updateUiForConfigDataMap(config); } }
@Override // DataApi.DataListener public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() != DataEvent.TYPE_CHANGED) { continue; } DataItem dataItem = dataEvent.getDataItem(); if (!dataItem.getUri().getPath().equals(SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) { continue; } DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); DataMap config = dataMapItem.getDataMap(); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Config DataItem updated:" + config); } updateUiForConfigDataMap(config); } }
/** * Update the views in the ViewHolder using the information in the * item in position i. */ @Override public void onBindViewHolder( WearableListView.ViewHolder viewHolder, int i) { // Find the DataItem for the item in position i. DataItem dataItem = dataItems.get(i); // Reconstruct the original DataMap for that item DataMap map = DataMapItem.fromDataItem(dataItem).getDataMap(); // Set the title view text based on the COLUMN_TITLE in the // DataMap ((ViewHolder) viewHolder).titleView.setText( map.getString(COLUMN_TITLE) ); }
@Override public void onDataChanged(DataEventBuffer dataEvents) { super.onDataChanged(dataEvents); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = dataEvent.getDataItem(); Uri uri = dataItem.getUri(); String path = uri.getPath(); if (path.startsWith("/filter")) { DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); int filterById = dataMap.getInt(DataMapKeys.FILTER); deviceClient.setSensorFilter(filterById); } } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { Log.d(TAG, "onDataChanged()"); for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataItem dataItem = dataEvent.getDataItem(); Uri uri = dataItem.getUri(); String path = uri.getPath(); if (path.startsWith("/sensors/")) { unpackSensorData( Integer.parseInt(uri.getLastPathSegment()), DataMapItem.fromDataItem(dataItem).getDataMap() ); } } } }
/** * Retrieve wear settings from Wear cloud storage */ public void updateSettings(Context context) { if (!googleApiClient.isConnected()) { if (!blockingConnect()) { return; } } ArrayList<DataMap> data; DataItemBuffer dataItemBuffer = Wearable.DataApi.getDataItems(googleApiClient).await(); if (dataItemBuffer.getStatus().isSuccess()) { for (DataItem dataItem : dataItemBuffer) { DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem); data = dataMapItem.getDataMap().getDataMapArrayList(WearableConstants.EXTRA_SETTINGS); if (data != null) { ListenerService.extractSettings(data); break; } } } dataItemBuffer.release(); }
public void fetchDataFromService(final DataItem item) { if (watchPaths.contains(item.getUri().getPath())) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); Map<String, Object> itemsMap = new HashMap<>(); for (String key : dataMap.keySet()) { if (watchKeys.contains(key)) { itemsMap.put(key, dataMap.get(key)); } } fetchData.put(item.getUri().getPath(), itemsMap); Intent updatedIntent = new Intent(item.getUri().getPath()); LocalBroadcastManager.getInstance(mContext).sendBroadcast(updatedIntent); } }
@Override public void onDataChanged(final DataEventBuffer dataEventBuffer) { for (final DataEvent event : dataEventBuffer) { final DataItem item = event.getDataItem(); final long id = ContentUris.parseId(item.getUri()); // Update the configuration only if ID matches if (id != mConfigurationId) continue; // Configuration added or edited if (event.getType() == DataEvent.TYPE_CHANGED) { final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); final UartConfiguration configuration = new UartConfiguration(dataMap, id); // Update UI on UI thread runOnUiThread(() -> mAdapter.setConfiguration(configuration)); } else if (event.getType() == DataEvent.TYPE_DELETED) { // Configuration removed // Update UI on UI thread runOnUiThread(() -> mAdapter.setConfiguration(null)); } } }
/** * This method read the UART configurations from the DataApi and populates the adapter with them. */ private void populateConfigurations() { if (mGoogleApiClient.isConnected()) { final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(mGoogleApiClient, 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); } mAdapter.setConfigurations(configurations); dataItems.release(); }); } }
/** * Builds notification for wear based on the data in the Data Item that is passed in. */ private void setupNotification(DataItem dataItem) { LOGD(TAG, "setupNotification(): DataItem=" + dataItem.getUri()); PutDataMapRequest putDataMapRequest = PutDataMapRequest .createFromDataMapItem(DataMapItem.fromDataItem(dataItem)); final DataMap dataMap = putDataMapRequest.getDataMap(); String sessionId = dataMap.getString(KEY_SESSION_ID); String sessionRoom = dataMap.getString(KEY_SESSION_ROOM); String sessionName = dataMap.getString(KEY_SESSION_NAME); String speakers = dataMap.getString(KEY_SPEAKER_NAME); int notificationId = (int) new Date().getTime(); Intent intent = new Intent(ACTION_DISMISS); intent.putExtra(KEY_SESSION_ID, dataMap.getString(KEY_SESSION_ID)); // need to be notified if user dismisses teh notification so we can dismiss the // corresponding notification on teh paired handset. PendingIntent deleteIntent = PendingIntent .getService(this, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent showCardIntent = showCardIntent(sessionId, sessionRoom, sessionName, speakers, notificationId); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) .setContentTitle(getString(R.string.rate_this_session)) .setDeleteIntent(deleteIntent) .setContentText(sessionName) .extend(new NotificationCompat.WearableExtender() .setDisplayIntent(showCardIntent)); NotificationManagerCompat.from(this) .notify(sessionId, NOTIFICATION_ID, builder.build()); }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { Log.d(TAG, "onDataChanged: " + dataEventBuffer); for (DataEvent event : dataEventBuffer) { if (event.getType() == DataEvent.TYPE_CHANGED) { // DataItem changed } else if (event.getType() == DataEvent.TYPE_DELETED) { // DataItem deleted } DataItem item = event.getDataItem(); if (item.getUri().getPath().compareTo("/forecast") == 0) { DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); updateUiforDataMap(dataMap); } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { DataItem dataItem = event.getDataItem(); final String path = dataItem.getUri().getPath(); DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap(); if (QUERY_YTLOGSTATUS_RESULT_PATH.equals(path)) { String res = dataMap.getString(PARAM_1); Intent intent = new Intent(MyWatchFaceService.ACTION_UPDATE); intent.putExtra(MyWatchFaceService.INTENTPARAM_PARAM1, res); sendBroadcast(intent); } } }