Search in sources :

Example 6 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, boolean value) {
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        // NEW_STATUS_PATH
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        // unique content
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        // "externalStatusString"
        dataMapRequest.getDataMap().putBoolean(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)

Example 7 with PutDataRequest

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

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 8 with PutDataRequest

use of com.google.android.gms.wearable.PutDataRequest in project Memento-Calendar by alexstyl.

the class WearSyncService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    if (!permissions.canReadAndWriteContacts()) {
        return;
    }
    Optional<ContactEventsOnADate> eventsOptional = fetchContactEvents();
    if (eventsOptional.isPresent()) {
        ContactEventsOnADate contactEvents = eventsOptional.get();
        PutDataRequest putDataRequest = createDataRequest(contactEvents);
        GoogleApiClient googleApiClient = new GoogleApiClient.Builder(getApplicationContext()).addApi(Wearable.API).build();
        if (googleApiClient.blockingConnect().isSuccess()) {
            Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
        }
    }
}
Also used : GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) PutDataRequest(com.google.android.gms.wearable.PutDataRequest) ContactEventsOnADate(com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)

Example 9 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, 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 10 with PutDataRequest

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

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)

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