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!");
}
}
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!");
}
}
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);
}
}
}
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!");
}
}
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!");
}
}
Aggregations