@Override public void onMessageReceived(MessageEvent messageEvent) { super.onMessageReceived(messageEvent); if (Constantes.MSG_SAIR.equals(messageEvent.getPath())) { enviarMsgSair(); } } private void enviarMsgSair() {
@Override public void onCreate() { super.onCreate(); mMessageReceivedHandlers.add(new CompanionPermissionRequestMessageHandler(this)); mWearableAPIHelper = new WearableAPIHelper(this, new WearableAPIHelper.WearableAPIHelperListener() { @Override public void onWearableAPIConnected(GoogleApiClient apiClient) { } @Override public void onWearableAPIConnectionSuspended(int cause) { } @Override public void onWearableAPIConnectionFailed(ConnectionResult result) { } }); }
@Override public void onDestroy() { Log.i(TAG, "destroy"); super.onDestroy(); }
@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(); } }
@Override public void onPeerConnected(Node peer) { super.onPeerConnected(peer); mWearUtil.conectar(); } @Override
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (null != intent) { String action = intent.getAction(); if (Constants.ACTION_DISMISS.equals(action)) { // We need to dismiss the wearable notification. We delete the data item that // created the notification and that is how we inform the phone int notificationId = intent.getIntExtra(Constants.KEY_NOTIFICATION_ID, -1); if (notificationId == Constants.BOTH_ID) { dismissPhoneNotification(notificationId); } } } return super.onStartCommand(intent, flags, startId); }
@Override public void onPeerDisconnected(final Node peer) { super.onPeerDisconnected(peer); NotificationManagerCompat.from(this).cancel(UART_NOTIFICATION_ID); } }
@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(); } } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (null != intent) { String action = intent.getAction(); if (Constants.ACTION_DISMISS.equals(action)) { // We need to dismiss the wearable notification. We delete the DataItem that // created the notification to inform the wearable. int notificationId = intent.getIntExtra(Constants.KEY_NOTIFICATION_ID, -1); if (notificationId == Constants.BOTH_ID) { dismissWearableNotification(notificationId); } } } return super.onStartCommand(intent, flags, startId); }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/message_path")) { final String message = new String(messageEvent.getData()); Log.v(TAG, "Message path received is: " + messageEvent.getPath()); Log.v(TAG, "Message received 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 onCreate() { super.onCreate(); mWearUtil = new WearUtil(this); mWearUtil.conectar(); } @Override
@Override public void onDestroy() { mWearableAPIHelper.onDestroy(); super.onDestroy(); }
@Override public void onPeerDisconnected(Node peer) { super.onPeerDisconnected(peer); enviarMsgSair(); mWearUtil.desconectar(); } private void lerNovosDados(DataEvent event) {
@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(); } } }
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (Constantes.ACAO_ANTERIOR.equals(intent.getAction())) { mWearUtil.enviarMensagem(Constantes.MSG_NAVEGACAO, new byte[]{Constantes.NAVEGACAO_ANTERIOR}); } else if (Constantes.ACAO_PROXIMO.equals(intent.getAction())) { mWearUtil.enviarMensagem(Constantes.MSG_NAVEGACAO, new byte[]{Constantes.NAVEGACAO_PROXIMO}); } return super.onStartCommand(intent, flags, startId); } @Override
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/message_path")) { final String message = new String(messageEvent.getData()); Log.v(TAG, "Message path received on phone is: " + messageEvent.getPath()); Log.v(TAG, "Message received on phone is: " + message); // Broadcast message to MainActivity 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 onCreate() { super.onCreate(); mAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE); mOrigVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_ALARM); mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM); mAlarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM); mMediaPlayer = new MediaPlayer(); }
@Override public void onDestroy() { // Reset the alarm volume to the user's original setting. mAudioManager.setStreamVolume(AudioManager.STREAM_ALARM, mOrigVolume, 0); mMediaPlayer.release(); super.onDestroy(); }
@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(); } }
@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); } }