@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/heartRate")) { final String message = new String(messageEvent.getData()); Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath()); Log.v("packtchat", "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("heart", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/stepcount")) { final String message = new String(messageEvent.getData()); Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath()); Log.v("packtchat", "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/message_path")) { final String message = new String(messageEvent.getData()); Log.v("myTag", "Message path received on watch is: " + messageEvent.getPath()); Log.v("myTag", "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/from-wear")) { final String message = new String(messageEvent.getData()); Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath()); Log.v("packtchat", "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/stepcount")) { final String message = new String(messageEvent.getData()); Log.v(TAG, "Message path received from wear is: " + messageEvent.getPath()); Log.v(TAG, "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
/** * 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(); } } }
@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) { Intent intent = new Intent(this, SpaceRemoteActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); long[] vibrationPattern = {0, 75, 50, 75}; vibrator.vibrate(vibrationPattern, -1); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { //This method will call while any message is posted by the watch to the phone. //This is message api, so if the phone is not connected message will be lost. //No guarantee of the message delivery //check path of the message if (messageEvent.getPath().equalsIgnoreCase(STEP_COUNT_MESSAGES_PATH)) { //Extract the values String stepCount = new String(messageEvent.getData()); Log.d("Step count: ", stepCount + " "); //send broadcast to update the UI in MainActivity based on the tracking status Intent intent = new Intent(TRACKING_COUNT_ACTION); intent.putExtra("step-count", stepCount); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); Log.d("WEAR", "Message received: " + messageEvent); nodeId = messageEvent.getSourceNodeId(); //Toast.makeText(this, "Command received", Toast.LENGTH_LONG).show(); if (messageEvent.getPath().contains(LAST_KNOW_GPS_POSITION)) { new Thread(){ @Override public void run() { super.run(); try { LocationManager locationManager = (LocationManager) WatchFaceWearableListenerService.this.getSystemService(Context.LOCATION_SERVICE); String locationProvider = LocationManager.NETWORK_PROVIDER; // Or use LocationManager.GPS_PROVIDER Location lastKnownLocation = locationManager.getLastKnownLocation(locationProvider); if(lastKnownLocation != null) { reply(LAST_KNOW_GPS_POSITION, lastKnownLocation.getLatitude() + "_" + lastKnownLocation.getLongitude()); } }catch (Exception e){e.printStackTrace();} } }.start(); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { String message = new String(messageEvent.getData()); if (messageEvent.getPath().equals(Constants.MYCROFT_QUERY_MESSAGE_PATH)) { Log.d(TAG, "MycroftWearRequest Message: " + message); Intent startIntent = new Intent(this, MainActivity.class); startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startIntent.putExtra("MYCROFT_WEAR_REQUEST", message); startActivity(startIntent); handoffWearRequest(message); } }
@Override public void onMessageReceived(MessageEvent messageEvent){ if( messageEvent.getPath().equalsIgnoreCase( "/saw_repl" ) ) { //String msg = messageEvent.getData(); Log.i("DEV", "Got queue sent confirmation!"); } else if (messageEvent.getPath().equalsIgnoreCase(SEND_UPDATE_REQUEST)){ try { sendQueueToWear(mQueue); } catch (JSONException e) { e.printStackTrace(); } } else if (messageEvent.getPath().equalsIgnoreCase(SEND_KICK_USER)){ kickUser(messageEvent.getData()); } else if (messageEvent.getPath().equalsIgnoreCase(SEND_ATTEND_USER)){ attendUser(messageEvent.getData()); } else { super.onMessageReceived( messageEvent ); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); if (messageEvent.getPath().equals("/BatteryLevel")) { String s = new String(messageEvent.getData()); Log.d(this.getClass().getSimpleName(), "受信したバッテリーレベル = " + s); MyWearApplication app = (MyWearApplication) getApplication(); try { app.setBatteryLevel(Integer.parseInt(s)); } catch (NumberFormatException e) { e.printStackTrace(); } } }
@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); String path = messageEvent.getPath(); switch (path) { case "/RequestBatteryLevel": Log.d(sTag, "バッテリーレベル要求を受信"); mApiClient = new GoogleApiClient.Builder( getApplicationContext(), mConnectionCallback, mConnFailedCallback) .addApi(Wearable.API) .build(); mApiClient.connect(); break; } }
@Override public void onMessageReceived(final MessageEvent messageEvent) { super.onMessageReceived(messageEvent); switch (messageEvent.getPath()) { case DataPaths.Messages.SEARCH_RESULT: WearSearchData.Results searchResults = null; final byte[] data = messageEvent.getData(); if (data != null && data.length != 0) { try { searchResults = WearSearchData.Results.parseFrom(data); } catch (InvalidProtocolBufferNanoException e) { Log.w(TAG, e); } } if (searchResults == null) { searchResults = new WearSearchData.Results(); } EventBus.getDefault().post(new EventSearchResults(searchResults)); break; } }
@Override public void onMessageReceived(MessageEvent messageEvent) { // Guard Clauses if (knownMessagePathList == null || knownMessagePathList.isEmpty()) { Log.e(getClass().getSimpleName(), "KnownMessagePathList is empty/null"); return; } else if (messageEvent == null || messageEvent.getPath() == null) { Log.e(getClass().getSimpleName(), "MessageEvent or its path is null"); return; } for (String knownMessagePath : knownMessagePathList) { if (messageEvent.getPath().equals(knownMessagePath)) { // Try to send a local broadcast, if it fails, send an intent if (canSendEventBusMessage()) { EventBus.getDefault().post(new WearExchangeMessageEvent(messageEvent)); } else { sendIntentMessage(messageEvent); } break; } } }
@Override public void onMessageReceived(MessageEvent event) { String path = event.getPath(); Log.d(TAG, "onMessageReceived: Path " + path); switch (path) { case Consts.Paths.START_ACTIVITY: startActivity(createActivityIntent(false)); break; case Consts.Paths.GAME_SHOT: GameState.getInstance().setIsShotTime(true); mVibrator.vibrate(VIBRATE_PATTERN, -1); startActivity(createActivityIntent(true)); break; case Consts.Paths.GAME_INFORMATION: GameState.getInstance().setIsShotTime(false); break; } super.onMessageReceived(event); }
/** * Android Wearのリスナーを設定する. */ private void setMessageListener() { Wearable.MessageApi.addListener(mGoogleApiClient, new MessageApi.MessageListener() { @Override public void onMessageReceived(final MessageEvent messageEvent) { final String data = new String(messageEvent.getData()); final String path = messageEvent.getPath(); final String nodeId = messageEvent.getSourceNodeId(); mLogger.info("onMessageReceived: path = " + path + ":node:" + nodeId); OnMessageEventListener listener = mOnMessageEventListeners.get(path); if (listener != null) { listener.onEvent(nodeId, data); } } }); }
/** * バイブレーションを開始する. * @param messageEvent メッセージ */ private void startVibration(final MessageEvent messageEvent) { // get vibration pattern String mPattern = new String(messageEvent.getData()); // Make array of pattern String[] mPatternArray = mPattern.split(",", 0); long[] mPatternLong = new long[mPatternArray.length + 1]; mPatternLong[0] = 0; for (int i = 1; i < mPatternLong.length; i++) { mPatternLong[i] = Integer.parseInt(mPatternArray[i - 1]); } Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE); vibrator.vibrate(mPatternLong, -1); }
@Override public void onMessageReceived(MessageEvent messageEvent) { String nodeId = messageEvent.getSourceNodeId(); String path = messageEvent.getPath(); byte[] payload = messageEvent.getData(); if (TextUtils.equals(path, Paths.GET_CART)) { getCart(nodeId); } else if (TextUtils.equals(path, Paths.MARK_CART_ELEMENT)) { markCartElement(payload); } else if (TextUtils.equals(path, Paths.CLEAR_SELECTED)) { clearSelected(); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (OPEN_URL_PATH.equals(messageEvent.getPath())) { SendHeadline receivedHeadline = new Gson().fromJson(new String(messageEvent.getData()), SendHeadline.class); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String readListPref = prefs.getString(getString(R.string.key_prefs_read_item_tap), "0"); boolean appShareFromWatch = prefs.getBoolean(getString(R.string.key_prefs_article_select_from_watch), false); if (appShareFromWatch && readListPref.equals(SettingsActivity.TAP_SPECIFIC_APP_VALUE)) { new DeviceAppService().shareToSpecificSelectedApp(this, receivedHeadline); } else { receivedHeadline.setInReadList(true); if (!HeadlinesService.isArticleInList(receivedHeadline.getArticleUrl())) { receivedHeadline.save(); } Intent intent = new Intent(this, FeedsMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(OPEN_READ_LIST_EXTRA, true); startActivity(intent); sendBroadcast(new Intent(getString(R.string.receive_headline_intent))); } } }
@Override public void onMessageReceived(MessageEvent message) { if (Paths.SYNC.equals(message.getPath())) { FWLog.i("Received a sync request; manually syncing all accounts"); SyncAdapter.requestManualSync(this); } else if (Paths.ACK.equals(message.getPath())) { Uri uri; try { uri = Uri.parse(new String(message.getData(), "UTF-8")); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("UTF-8 must be a supported encoding", e); } FWLog.d("Received an ACK for URI %s", uri); LocalBroadcasts.sendAckBroadcast(this, uri); } else { FWLog.e("Unknown message path: %s", message.getPath()); } }
@Override public void onMessageReceived( final MessageEvent messageEvent ) { Log.d ( TAG, "onMessageReceived() messageEvent=" + messageEvent) ; Log.d(TAG, "onMessageReceived() messageEvent=" + messageEvent.getPath() + " " + messageEvent.getSourceNodeId() + " " + new String ( messageEvent.getData() ) ) ; //dataTextView.setText( new String (messageEvent.getData()) ); runOnUiThread(new Runnable() { @Override public void run() { // dataTextView.setText(messageEvent.getPath() + messageEvent.getSourceNodeId() + String.valueOf(messageEvent.getData())); //dataTextView.setText( String.valueOf(messageEvent.getData() )); dataTextView.setText( new String (messageEvent.getData() )); } }); }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/MainActivity")) { final String message = new String(messageEvent.getData()); Log.i(TAG, "Message path received on watch is: " + messageEvent.getPath()); Log.i(TAG, "Message received on watch is: " + message); Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("message", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { // new request to start the app // all this should probably happen only if notification not up/app is really starting if (messageEvent.getPath().equals(Constants.COMM_START)) { NotificationUtils.issueNotification("amaroKontrol", "", null, null); Commander.getInstance().sendCommand(Constants.COMM_FORCE_REFRESH, null); } // request to clera notification - app on phone has ended else if (messageEvent.getPath().equals(Constants.COMM_CLEAR_NOTIFICATION)) { Log.d("clearing notification from wear"); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancelAll(); } }
/** * This method is called when a message from a wearable device is received * * @param messageEvent */ @Override public void onMessageReceived(MessageEvent messageEvent) { LogHandler.configureLogger(); if (messageEvent.getPath().equals(WearableConstants.RECEIVER_ACTION_TRIGGER_PATH)) { String messageData = new String(messageEvent.getData()); Log.d("Wear_ListenerService", "Message received: " + messageData); // trigger api intent parseMessage(messageData); } else if (messageEvent.getPath().equals(WearableConstants.REQUEST_DATA_UPDATE_PATH)) { UtilityService.forceWearDataUpdate(this); } else if (messageEvent.getPath().equals(WearableConstants.REQUEST_SETTINGS_UPDATE_PATH)) { UtilityService.forceWearSettingsUpdate(this); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (Log.isLoggable(Constants.LOG_TAG, Log.DEBUG)) { Log.d(Constants.LOG_TAG, "onDataChanged: " + messageEvent); } final String messagePath = messageEvent.getPath(); if(messagePath != null){ if(messagePath.equals(Constants.NEXT_SLIDE_GESTURE_DETECTED_PATH)) { Log.d(Constants.LOG_TAG, "Next slide message received from Wear device..."); Intent intent = new Intent(SendMessageReceiver.INTENT); intent.putExtra(Constants.EXTRA_MESSAGE, Constants.NEXT_SLIDE_MESSAGE); sendBroadcast(intent); } else{ Log.i(Constants.LOG_TAG, "Received message with unknown path: " + messagePath); } } else{ Log.e(Constants.LOG_TAG, "Message with null path: " + messageEvent); } }
@Override public void onMessageReceived(MessageEvent _messageEvent) { final String temp = _messageEvent.getPath(); if (temp.equals(MyConstants.PATH_STOP)) { finish(); }else if (temp.equals(MyConstants.PATH_START_RECORDING)) { Log.i(TAG,"wear path start recording received"); runOnUiThread(new Runnable() { @Override public void run() { startRedDotAnimation(); } }); //TODO: implement counter here }else if(temp.equals(MyConstants.PATH_STOP_RECORDING)){ Log.i(TAG,"wear path stop recording received"); runOnUiThread(new Runnable() { @Override public void run() { stopRedDotAnimation(); } }); //TODO: implement counter here } }
public Emmet onCreate(Context context, ConnectionListener connectionListener) { mConnectionListener = connectionListener; mApiClient = new GoogleApiClient.Builder(context.getApplicationContext()) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); Wearable.MessageApi.addListener(mApiClient, new MessageApi.MessageListener() { @Override public void onMessageReceived(MessageEvent messageEvent) { onMessageReceived(messageEvent); } }); Wearable.DataApi.addListener(mApiClient, new DataApi.DataListener() { @Override public void onDataChanged(DataEventBuffer dataEventBuffer) { onDataChanged(dataEventBuffer); } }); mApiClient.connect(); return this; }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals(START_ACTIVITY_PATH)) { String message = new String(messageEvent.getData()); if (message.equals("NewLocation")) { Log.d(TAG, "Got message for New Location"); Intent promptIntent = new Intent(getApplicationContext(), PromptActivity.class); promptIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(promptIntent); } else if (message.startsWith("MEAN")){ String[] messageHalves = message.split(","); String[] mean = messageHalves[0].split(":"); String[] stdev = messageHalves[1].split(":"); Log.d(TAG, "Got message for mean and stdev"); SharedPreferences prefs = getSharedPreferences("FuzzyTime", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putInt("key_mean", Integer.valueOf(mean[1])); editor.putInt("key_stdev", Integer.valueOf(stdev[1])); editor.apply(); } } }
@Override public void onMessageReceived(final MessageEvent messageEvent) { if (messageEvent.getPath().equals(receiverPath)) { ((Activity)context).runOnUiThread(new Runnable() { @Override public void run() { String data = null; try { data = new String(messageEvent.getData(),"UTF-8"); messageReceived.messageReceived(messageEvent.getPath(), data); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } }); } }
@Override public void onMessageReceived(MessageEvent messageEvent) { Log.d(Constants.TAG, "onMessageReceived " + messageEvent.getPath() + " " + messageEvent.getRequestId() ); if (messageEvent.getPath().equals(Constants.WEAR_GA_PATH)) { Parcel parcel = Parcel.obtain(); parcel.unmarshall(messageEvent.getData(), 0, messageEvent.getData().length); parcel.setDataPosition(0); AnalyticsEvent event = (AnalyticsEvent) AnalyticsEvent.CREATOR.createFromParcel(parcel); tracker.send(new HitBuilders.EventBuilder() .setCategory(event.getCategory()) .setAction(event.getAction()) .setLabel(event.getLabel()) .setValue(event.getValue()) .build()); Log.d(Constants.TAG, "sending analytics "); } }
@Override public void onMessageReceived(MessageEvent event) { Log.d(TAG, "onMessageReceived: " + event); switch (event.getPath()) { case Consts.Paths.GAME_SHOT: Log.d(TAG, "onMessageReceived: SHOT TIME"); GameState.getInstance().setIsShotTime(true); mGameScreen.updateScreen(isAmbient()); break; case Consts.Paths.GAME_STOP: Log.d(TAG, "onMessageReceived: Game has stopped"); GameState.getInstance().stop(); updateDisplay(); Message.sendReady(this); break; case Consts.Paths.GAME_FINISH: Log.i(TAG, "onMessageReceived: Game has finished"); Wearable.DataApi.removeListener(mGoogleApiClient, this); Wearable.MessageApi.removeListener(mGoogleApiClient, this); finish(); break; } }
@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); SoundProfile profile = SoundProfile.valueOf(messageEvent.getPath()); switch (profile) { case SOUND_ON: audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); break; case SOUND_OFF: audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); break; case VIBRATE: audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE); break; } Log.d(Const.TAG, "on profile changed: " + profile.name()); }
@Override public void onMessageReceived(MessageEvent messageEvent) { String nodeId = messageEvent.getSourceNodeId(); String path = messageEvent.getPath(); String payload = EncodingHelper.getBytesAsString(messageEvent.getData()); if (TextUtils.equals(path, Paths.GET_FAVORITE_STOPS)) { getFavoriteStops(nodeId); } else if (TextUtils.equals(path, Paths.GET_DEPARTURES)) { getDepartures(nodeId, payload); } else if (TextUtils.equals(path, Paths.GET_TRIP)) { getTrip(nodeId, payload); } else if (TextUtils.equals(path, Paths.INCREASE_STOP_HIT_COUNT)) { increaseStopHitCount(payload); } }