Search in sources :

Example 16 with PutDataRequest

use of com.google.android.gms.wearable.PutDataRequest in project xDrip by NightscoutFoundation.

the class WatchUpdaterService method sendRequestExtra.

private void sendRequestExtra(String path, String key, byte[] value) {
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        dataMapRequest.getDataMap().putByteArray(key, value);
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        dataMapRequest.setUrgent();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
        Log.d(TAG, "Sending bytes path: " + path + " " + value.length);
    } else {
        Log.e("sendRequestExtra", "No connection to wearable available!");
    }
}
Also used : PutDataRequest(com.google.android.gms.wearable.PutDataRequest) PutDataMapRequest(com.google.android.gms.wearable.PutDataMapRequest)

Example 17 with PutDataRequest

use of com.google.android.gms.wearable.PutDataRequest in project xDrip by NightscoutFoundation.

the class WatchUpdaterService method sendDataReceived.

private void sendDataReceived(String path, String notification, long timeOfLastEntry, String type, long watch_syncLogsRequested) {
    // KS
    Log.d(TAG, "sendDataReceived timeOfLastEntry=" + JoH.dateTimeText(timeOfLastEntry) + " Path=" + path);
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        dataMapRequest.setUrgent();
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        dataMapRequest.getDataMap().putLong("timeOfLastEntry", timeOfLastEntry);
        dataMapRequest.getDataMap().putLong("syncLogsRequested", watch_syncLogsRequested);
        dataMapRequest.getDataMap().putString("type", type);
        dataMapRequest.getDataMap().putString("msg", notification);
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
    } else {
        Log.e(TAG, "sendDataReceived No connection to wearable available!");
    }
}
Also used : PutDataRequest(com.google.android.gms.wearable.PutDataRequest) PutDataMapRequest(com.google.android.gms.wearable.PutDataMapRequest)

Example 18 with PutDataRequest

use of com.google.android.gms.wearable.PutDataRequest in project xDrip-plus by jamorham.

the class WatchUpdaterService method sendNotification.

private void sendNotification(String path, String notification) {
    // KS add args
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        Log.d(TAG, "sendNotification Notification=" + notification + " Path=" + path);
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        // unique content
        dataMapRequest.setUrgent();
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        dataMapRequest.getDataMap().putString(notification, notification);
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
    } else {
        Log.e(TAG, "sendNotification No connection to wearable available!");
    }
}
Also used : PutDataRequest(com.google.android.gms.wearable.PutDataRequest) PutDataMapRequest(com.google.android.gms.wearable.PutDataMapRequest)

Example 19 with PutDataRequest

use of com.google.android.gms.wearable.PutDataRequest in project xDrip-plus by jamorham.

the class WatchUpdaterService method sendRequestExtra.

private void sendRequestExtra(String path, String key, String value) {
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        // NEW_STATUS_PATH
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        // unique content
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        // "externalStatusString"
        dataMapRequest.getDataMap().putString(key, value);
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
    } else {
        Log.e("sendRequestExtra", "No connection to wearable available!");
    }
}
Also used : PutDataRequest(com.google.android.gms.wearable.PutDataRequest) PutDataMapRequest(com.google.android.gms.wearable.PutDataMapRequest)

Aggregations

PutDataRequest (com.google.android.gms.wearable.PutDataRequest)19 PutDataMapRequest (com.google.android.gms.wearable.PutDataMapRequest)18 DataApi (com.google.android.gms.wearable.DataApi)2 DataMap (com.google.android.gms.wearable.DataMap)2 Node (com.google.android.gms.wearable.Node)2 NodeApi (com.google.android.gms.wearable.NodeApi)2 ContactEventsOnADate (com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1