Java Code Examples for com.google.android.gms.wearable.MessageEvent#getData()

The following examples show how to use com.google.android.gms.wearable.MessageEvent#getData() . 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: WearService.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 2
Source File: ListenerService.java    From wearable with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 3
Source File: PlayNetwork.java    From CrossBow with Apache License 2.0 6 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    if(messageEvent.getPath().contains("crossbow_wear")) {
        byte[] data = messageEvent.getData();
        Log.d("Play Network", "request response returned");
        try {
            WearNetworkResponse wearNetworkResponse = WearNetworkResponse.fromByteArray(data);
            String uuid = wearNetworkResponse.uuid;
            responsesMap.put(uuid, wearNetworkResponse);

            if(latchMap.containsKey(uuid)) {
                //unlatch the correct thread
                Log.d("Play Network", "unlatching thread");
                latchMap.get(uuid).countDown();
            }
        }
        catch (Exception e) {
            Log.d("Play Network", "wearNetworkResponse error = " + e);
        }
        Log.d("Play Network", "request response returned");
    }
}
 
Example 4
Source File: MainActivity.java    From wearable with Apache License 2.0 6 votes vote down vote up
/**
 *  The listener is in the code, in this example (instead in a separate listener).
 *  note, the listener is removed when the activity is paused.
 */
@Override
public void onMessageReceived(@NonNull MessageEvent messageEvent) {
    Log.d(TAG, "onMessageReceived() A message from watch was received:"
        + messageEvent.getRequestId() + " " + messageEvent.getPath());
    if (messageEvent.getPath().equals("/message_path")) {  //don't think this if is necessary anymore.
        String message =new String(messageEvent.getData());
        Log.v(TAG, "Wear activity received message: " + message);
        // Display message in UI
        mTextView.setText(message);
        //here, send a message back.
        message = "Hello device " + num;
        //Requires a new thread to avoid blocking the UI
        new SendThread(datapath, message).start();
        num++;
    }
}
 
Example 5
Source File: ListenerService.java    From AnkiDroid-Wear with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
        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);

        Intent messageIntent = new Intent();
        messageIntent.setAction(Intent.ACTION_SEND);
        messageIntent.putExtra("path", messageEvent.getPath());
        messageIntent.putExtra("message", new String(messageEvent.getData()));
        LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);


        super.onMessageReceived(messageEvent);

}
 
Example 6
Source File: ListenerService.java    From wearable with Apache License 2.0 6 votes vote down vote up
@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);
    }
}
 
Example 7
Source File: DataLayerListenerService.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
/**
 * バイブレーションを開始する.
 * @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);
}
 
Example 8
Source File: MainActivity.java    From TutosAndroidFrance with MIT License 5 votes vote down vote up
/**
 * Appellé à la réception d'un message envoyé depuis le smartphone
 *
 * @param messageEvent message reçu
 */
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    //traite le message reçu
    final String path = messageEvent.getPath();
    //récupère le contenu du message
    final String message = new String(messageEvent.getData());

    if (path.equals("bonjour")) {
        elementList = new ArrayList<>();
        elementList.add(new Element("Message reçu", message, Color.parseColor("#F44336")));
        startMainScreen();
    }
}
 
Example 9
Source File: WearMessageService.java    From CrossBow with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    super.onMessageReceived(messageEvent);
    if(!isCrossBowMessage(messageEvent)) {
        String path = messageEvent.getPath();
        String data = new String(messageEvent.getData());

        Toast.makeText(this, "Message Received from Path - " + path + ", data = " + data, Toast.LENGTH_SHORT).show();
    }
}
 
Example 10
Source File: WatchService.java    From WearPay with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    String path = messageEvent.getPath();
    if (path.equals(PATH_CODE)) {
        String code = new String(messageEvent.getData());
    } else if (path.equals(PATH_PAY_SUCCESS)) {
        wearPayBinder.onPaySuccess();
    }
}
 
Example 11
Source File: EventBus.java    From BusWear with Apache License 2.0 5 votes vote down vote up
/**
 * Will take a MessageEvent from GooglePlayServices and attempt to parse WearEventBus data to sync with the local EventBus
 *
 * @param messageEvent
 */
public void syncEvent(@NonNull MessageEvent messageEvent) {
    byte[] objectArray = messageEvent.getData();

    int indexClassDelimiter = messageEvent.getPath().lastIndexOf(WearBusTools.CLASS_NAME_DELIMITER);
    String className = messageEvent.getPath().substring(indexClassDelimiter + 1);

    boolean isEventMessage = messageEvent.getPath().contains(WearBusTools.MESSAGE_PATH) || messageEvent.getPath().contains(WearBusTools.MESSAGE_PATH_STICKY);

    if (isEventMessage) {

        //Try simple types (String, Integer, Long...)
        Object obj = WearBusTools.getSendSimpleObject(objectArray, className);

        if (obj == null) {
            //Find corresponding parcel for particular object in local receivers
            obj = findParcel(objectArray, className);
        }

        if (obj != null) {

            boolean isSticky = messageEvent.getPath().contains(WearBusTools.MESSAGE_PATH_STICKY);

            //send them to local bus
            if (isSticky) {
                postStickyLocal(obj);
            } else {
                postLocal(obj);
            }
        }

    } else if (messageEvent.getPath().contains(WearBusTools.MESSAGE_PATH_COMMAND)) {

        //Commands used for managing sticky events.
        stickyEventCommand(messageEvent, objectArray, className);
    }
}
 
Example 12
Source File: WatchFaceConfigListenerService.java    From american-sunsets-watch-face with Apache License 2.0 5 votes vote down vote up
@Override // WearableListenerService
public void onMessageReceived(MessageEvent messageEvent) {
    if (!messageEvent.getPath().equals(SunsetsWatchFaceUtil.PATH_WITH_FEATURE)) {
        return;
    }
    byte[] rawData = messageEvent.getData();
    // It's allowed that the message carries only some of the keys used in the config DataItem
    // and skips the ones that we don't want to change.
    DataMap configKeysToOverwrite = DataMap.fromByteArray(rawData);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Received watch face config message: " + configKeysToOverwrite);
    }

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Wearable.API).build();
    }
    if (!mGoogleApiClient.isConnected()) {
        ConnectionResult connectionResult =
                mGoogleApiClient.blockingConnect(30, TimeUnit.SECONDS);

        if (!connectionResult.isSuccess()) {
            Log.e(TAG, "Failed to connect to GoogleApiClient.");
            return;
        }
    }

    SunsetsWatchFaceUtil.overwriteKeysInConfigDataMap(mGoogleApiClient, configKeysToOverwrite);
}
 
Example 13
Source File: Emmet.java    From Wear-Emmet with Apache License 2.0 5 votes vote down vote up
public Emmet onMessageReceived(MessageEvent messageEvent) {
    if (messageEvent.getPath().startsWith(PATH)) {
        String messageName = new String(messageEvent.getData());
        callMethodOnInterfaces(messageName);
    }
    return this;
}
 
Example 14
Source File: MainWearableListenerService.java    From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
	switch (messageEvent.getPath()) {
		case Constants.ACTION_DISCONNECT: {
			// A disconnect message was sent. The information which profile should be disconnected is in the data.
			final String profile = new String(messageEvent.getData());

			//noinspection SwitchStatementWithTooFewBranches
			switch (profile) {
				// Currently only UART profile has Wear support
				case Constants.UART.PROFILE: {
					final Intent disconnectIntent = new Intent(UARTService.ACTION_DISCONNECT);
					disconnectIntent.putExtra(UARTService.EXTRA_SOURCE, UARTService.SOURCE_WEARABLE);
					sendBroadcast(disconnectIntent);
					break;
				}
			}
			break;
		}
		case Constants.UART.COMMAND: {
			final String command = new String(messageEvent.getData());

			final Intent intent = new Intent(UARTService.ACTION_SEND);
			intent.putExtra(UARTService.EXTRA_SOURCE, UARTService.SOURCE_WEARABLE);
			intent.putExtra(Intent.EXTRA_TEXT, command);
			sendBroadcast(intent);
		}
		default:
			super.onMessageReceived(messageEvent);
			break;
	}
}
 
Example 15
Source File: DigitalWatchFaceConfigListenerService.java    From wear-os-samples with Apache License 2.0 5 votes vote down vote up
@Override // WearableListenerService
public void onMessageReceived(MessageEvent messageEvent) {

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onMessageReceived: " + messageEvent);
    }

    if (!messageEvent.getPath().equals(DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
        return;
    }
    byte[] rawData = messageEvent.getData();
    // It's allowed that the message carries only some of the keys used in the config DataItem
    // and skips the ones that we don't want to change.
    DataMap configKeysToOverwrite = DataMap.fromByteArray(rawData);
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Received watch face config message: " + configKeysToOverwrite);
    }

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).addApi(Wearable.API).build();
    }
    if (!mGoogleApiClient.isConnected()) {
        ConnectionResult connectionResult =
                mGoogleApiClient.blockingConnect(30, TimeUnit.SECONDS);

        if (!connectionResult.isSuccess()) {
            Log.e(TAG, "Failed to connect to GoogleApiClient.");
            return;
        }
    }

    DigitalWatchFaceUtil.overwriteKeysInConfigDataMap(mGoogleApiClient, configKeysToOverwrite, null);
}
 
Example 16
Source File: WearProviderService.java    From cordova-androidwear with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessageReceived(@NonNull MessageEvent messageEvent) {
	LOGD(TAG, "onMessageReceived");
	if (messageEvent.getPath().equals(MESSAGE_PATH)) {
		final String message = new String(messageEvent.getData());
		messageReceived(messageEvent.getSourceNodeId(), message);
	}
}
 
Example 17
Source File: WearMessageListener.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
  Log.i("test", "onMessageReceived()");
  if(MESSAGE_PATH.equals(messageEvent.getPath())) {
    Parcel p = Parcel.obtain();
    byte[] data = messageEvent.getData();
    p.unmarshall(data, 0, data.length);
    p.setDataPosition(0);
    MotionEvent e = MotionEvent.CREATOR.createFromParcel(p);
    mMapView.onTouchEvent(e);
  }
}
 
Example 18
Source File: RequestListenerService.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
/**
 * Handles issuing a response to a FeatureType request. A FeatureType request
 * indicates that the Wear devices wants a list of available FeatureTypes for
 * the selected layer to display to the user.
 *
 * @param event the MessageEvent from the Wear device
 * @param client the Google API client used to communicate
 */
private void handleFeatureTypeRequest(MessageEvent event, GoogleApiClient client) {
  // Get the name and URL of the layer that was selected
  String layerName = new String(event.getData());
  String url = sLayerMap.get(layerName);
  // Create an ArcGISFeatureLayer with the specified URL
  sArcGISFeatureLayer = new ArcGISFeatureLayer(url, ArcGISFeatureLayer.MODE.SNAPSHOT);

  // While this isn't good practice, there is no way to be notified that an
  // ArcGISFeatureLayer has loaded its LayerServiceInfo. The OnStatusChangedListener
  // seems to be more relevant when the layer is actually being added to a MapView.
  // As such, we simply do a quick sleep until the LayerServiceInfo has been loaded
  try {
    while (sArcGISFeatureLayer.getLayerServiceInfo() == null) {
      Thread.sleep(500);
    }
  } catch (Exception e) {
    //
  }
  // Create a PutDataMapRequest with the FeatureType response path
  PutDataMapRequest req = PutDataMapRequest.create(FEATURE_TYPE_RESPONSE);
  DataMap dm = req.getDataMap();
  // Put an array list of the FeatureType names into the data map
  dm.putStringArrayList("featureTypes", FeatureLayerUtil.getFeatureTypes(sArcGISFeatureLayer));
  // Put the current time into the data map, which forces an onDataChanged event (this event
  // only occurs when data actually changes, so putting the time ensures something always changes)
  dm.putLong("Time", System.currentTimeMillis());
  // Put the DataItem into the Data API stream
  Wearable.DataApi.putDataItem(client, req.asPutDataRequest());
}
 
Example 19
Source File: DataLayerListenerService.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public void onMessageReceived(final MessageEvent messageEvent) {
    // get id of wear device
    String id = messageEvent.getSourceNodeId();
    String action = messageEvent.getPath();
    if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_RUN)) {
        startVibration(messageEvent);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_VIBRATION_DEL)) {
        stopVibration();
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_CANCAS_DELETE_IMAGE)) {
        deleteCanvas();
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_REGISTER)) {
        startSensorService(id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_DEIVCEORIENTATION_UNREGISTER)) {
        stopSensorService(id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONDOWN_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONUP_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER)) {
        startKeyEventActivity(WearConst.DEVICE_TO_WEAR_KEYEVENT_ONKEYCHANGE_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCHANGE_REGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCH_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHSTART_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHEND_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONDOUBLETAP_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHMOVE_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER)) {
        startTouchActivity(WearConst.DEVICE_TO_WEAR_TOUCH_ONTOUCHCANCEL_UNREGISTER, id);
    } else if (action.equals(WearConst.DEVICE_TO_WEAR_SET_ID)) {
        String wearId = new String(messageEvent.getData());
        ((WearApplication) getApplication()).setSelfId(wearId);
    } else {
        if (BuildConfig.DEBUG) {
            Log.e("Wear", "unknown event:" + action);
        }
    }
}
 
Example 20
Source File: WearService.java    From LibreAlarm with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onMessageReceived(MessageEvent messageEvent) {
    String data = new String(messageEvent.getData(), Charset.forName("UTF-8"));
    Log.i(TAG, "Message receiver: " + messageEvent.getPath() + ", " + data);
    switch (messageEvent.getPath()) {
        case WearableApi.CANCEL_ALARM:
            stopAlarm();
            break;
        case WearableApi.SETTINGS:
            Toast.makeText(this, R.string.settings_updated_on_watch, Toast.LENGTH_LONG).show();
            HashMap<String, String> prefs = PreferencesUtil.toMap(data);
            for (String key : prefs.keySet()) {
                PreferencesUtil.putString(this, key + QuickSettingsItem.WATCH_VALUE, prefs.get(key));
            }

            if (mListener != null) mListener.onWatchSettingsUpdated();
            break;
        case WearableApi.STATUS:
            mReadingStatus = new Gson().fromJson(data, Status.class);
            Status.Type type = mReadingStatus.status;
            if (type == Status.Type.ALARM_HIGH || type == Status.Type.ALARM_LOW) {
                startAlarm(mReadingStatus);
            } else {
                stopAlarm();
            }
            updateAlarmReceiver(type != Status.Type.NOT_RUNNING);
            updateNotification(type != Status.Type.NOT_RUNNING);
            if (mListener != null) mListener.onDataUpdated();
            break;
        case WearableApi.GLUCOSE:
            ReadingData.TransferObject object =
                    new Gson().fromJson(data, ReadingData.TransferObject.class);
            if (mLastReading == null || mLastReading.realDate < object.data.prediction.realDate) {
                mLastReading = object.data.prediction;
                if (mAlarmReceiverIsRunning) AlarmReceiver.post(this);
                updateNotification((mReadingStatus.status == null ? null : mReadingStatus.status != Status.Type.NOT_RUNNING));
            }

            mDatabase.storeReading(object.data);
            WearableApi.sendMessage(mGoogleApiClient, WearableApi.GLUCOSE, String.valueOf(object.id), null);
            if (mListener != null) mListener.onDataUpdated();
            if (PreferencesUtil.isXdripPlusEnabled(this)) XdripPlusBroadcast.syncXdripPlus(getApplicationContext(),data,object,getBatteryLevel());
            if (PreferencesUtil.isNsRestEnabled(this)) syncNightscout();
            runTextToSpeech(object.data.prediction);
            break;
    }
}