@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { for (DataEvent dataEvent : dataEventBuffer) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap(); String path = dataEvent.getDataItem().getUri().getPath(); Log.v("BuntinLog", "onDataChanged hit"); final String WEAR_PATH = "/sunshinewear"; final String WEAR_HIGH = "high"; final String WEAR_LOW = "low"; final String WEAR_WEATHER_ID = "weatherId"; if (path.equals(WEAR_PATH)) { if (dataMap.containsKey(WEAR_HIGH)) { mHigh = dataMap.getString(WEAR_HIGH); } if (dataMap.containsKey(WEAR_LOW)) { mLow = dataMap.getString(WEAR_LOW); } if (dataMap.containsKey(WEAR_WEATHER_ID)) { int weatherId = dataMap.getInt(WEAR_WEATHER_ID); mWeatherImage = Utility.getImages(weatherId); } } invalidate(); } } }
@Override public void onDataChanged(DataEventBuffer dataEventBuffer) { for (DataEvent event : dataEventBuffer) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataItem item = event.getDataItem(); DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); if (item.getUri().getPath().compareTo("/headReq") == 0) { if (dataMap.getInt("head") == 1 && gameStatus == true) { sendHeadVector(); } } else if (item.getUri().getPath().compareTo("/" + RESUME) == 0) { if (dataMap.getInt(RESUME) == 1) { gameStatus = true; } } else if (item.getUri().getPath().compareTo("/" + PAUSE) == 0) { if (dataMap.getInt(PAUSE) == 1) { gameStatus = false; } } else if (item.getUri().getPath().compareTo("/" + RESTART) == 0) { if (dataMap.getInt(RESTART) == 1) { gameStatus = true; } } } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { DataMap map = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); String path = event.getDataItem().getUri().getPath(); if ("/sunshine".equals(path)) { high = map.getDouble("temp-high"); low = map.getDouble("temp-low"); weatherId = map.getInt("weather-id"); Log.d(LOG_TAG, high + "-" + low + "-" + weatherId); Intent intent = new Intent("weather-data"); intent.putExtra("temp-high", high); intent.putExtra("temp-low", low); intent.putExtra("weather-id", weatherId); LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intent); } } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_DELETED) { Log.d("TAG", "DataItem deleted: " + event.getDataItem().getUri()); } else if (event.getType() == DataEvent.TYPE_CHANGED) { Log.d("TAG", "DataItem changed: " + event.getDataItem().getUri()); DataMap dataMap = DataMap.fromByteArray(event.getDataItem().getData()); // variable = dataMap.get~("keyname"); で受け取る runOnUiThread( new Runnable() { @Override public void run() { // 受け取り後の処理をここに // resultview.setText(resultstr); } }); } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap(); String message = dataMap.getString(Constants.KEY_TEXT_FROM_SERVER); String type = dataMap.getString(Constants.KEY_MESSAGE_TYPE); String path = dataEvent.getDataItem().getUri().getPath(); if (Constants.MESSAGE_WEARABLE_TO_MOBILE_PATH.equals(path)) { sendMessageToActivity(message, type); } } else if (dataEvent.getType() == DataEvent.TYPE_DELETED) { Log.d(TAG, "Message deleted"); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "DataItem deleted: " + dataEvent.getDataItem().getUri().getPath()); } if (Constants.MESSAGE_WEARABLE_TO_MOBILE_PATH.equals( dataEvent.getDataItem().getUri().getPath())) {} } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { for (DataEvent dataEvent : dataEvents) { if (dataEvent.getType() == DataEvent.TYPE_CHANGED) { if (Constants.NOTIFICATION_PATH.equals(dataEvent.getDataItem().getUri().getPath())) { DataMapItem dataMapItem = DataMapItem.fromDataItem(dataEvent.getDataItem()); String title = dataMapItem.getDataMap().getString(Constants.NOTIFICATION_TITLE); String content = dataMapItem.getDataMap().getString(Constants.NOTIFICATION_CONTENT); sendNotification(title, content); } } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { DataMap dataMap; for (DataEvent event : dataEvents) { if (event.getType() == DataEvent.TYPE_CHANGED) { String path = event.getDataItem().getUri().getPath(); if (path.equals(PATH_WEATHER_INFO)) {} dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtras(dataMap.toBundle()); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } } }
@Override public void onDataChanged(DataEventBuffer dataEvents) { DataMap dataMap; for (DataEvent event : dataEvents) { // Check the data type if (event.getType() == DataEvent.TYPE_CHANGED) { // Check the data path dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); String path = event.getDataItem().getUri().getPath(); if (path.equals(WEARABLE_TO_PHONE_DATA_PATH) && dataMap.containsKey(ACTION_KEY)) { doAction(dataMap.getString(ACTION_KEY), dataMap); } } } }
public g(DataEvent dataevent) { AQ = dataevent.getType(); alE = (DataItem) dataevent.getDataItem().freeze(); }