本文整理匯總了Java中com.google.android.gms.wearable.PutDataMapRequest.setUrgent方法的典型用法代碼示例。如果您正苦於以下問題:Java PutDataMapRequest.setUrgent方法的具體用法?Java PutDataMapRequest.setUrgent怎麽用?Java PutDataMapRequest.setUrgent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.android.gms.wearable.PutDataMapRequest
的用法示例。
在下文中一共展示了PutDataMapRequest.setUrgent方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putConfigDataItem
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
/**
* Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}.
* If the config DataItem doesn't exist, it's created.
*/
public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig) {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE);
putDataMapRequest.setUrgent();
DataMap configToPut = putDataMapRequest.getDataMap();
configToPut.putAll(newConfig);
Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus());
}
}
});
}
示例2: putConfigDataItem
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
/**
* Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}.
* If the config DataItem doesn't exist, it's created.
*/
public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig) {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE);
putDataMapRequest.setUrgent();
DataMap configToPut = putDataMapRequest.getDataMap();
configToPut.putAll(newConfig);
Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus());
}
});
}
示例3: sendDataReceived
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
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!");
}
}
示例4: sendTreatment
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public static void sendTreatment(double carbs, double insulin, double bloodtest, double timeoffset, String timestring) {
if ((googleApiClient != null) && (googleApiClient.isConnected())) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WEARABLE_TREATMENT_PAYLOAD);
//unique content
dataMapRequest.setUrgent();
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putDouble("carbs", carbs);
dataMapRequest.getDataMap().putDouble("insulin", insulin);
dataMapRequest.getDataMap().putDouble("bloodtest", bloodtest);
dataMapRequest.getDataMap().putDouble("timeoffset", timeoffset);
dataMapRequest.getDataMap().putString("timestring", timestring);
dataMapRequest.getDataMap().putBoolean("ismgdl", doMgdl(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext())));
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
Log.e(TAG, "No connection to wearable available for send treatment!");
}
}
示例5: syncData
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void syncData(PutDataMapRequest putDataMapRequest, boolean isUrgent) {
assertApiConnectivity();
if (isUrgent) {
putDataMapRequest = putDataMapRequest.setUrgent();
}
PutDataRequest request = putDataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
if (dataItemResult.getStatus().isSuccess()) {
WearUtil.logD(TAG, "putDataItem success");
} else {
String errStr = dataItemResult.getStatus().getStatusMessage();
Log.e(TAG, "ERROR: failed to putDataItem, status code: "
+ dataItemResult.getStatus().getStatusCode()
+ ",status message:"
+ errStr);
}
}
});
}
示例6: sendWeatherDataToWatch
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void sendWeatherDataToWatch() {
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create("/weather");
if (hightempforwatch != 0) {
putDataMapRequest.getDataMap().putInt("highTemp", hightempforwatch);
Log.d("Test","High Temp :"+String.valueOf(putDataMapRequest.getDataMap().getInt("highTemp")));
}
if (lowtempforWatch != 0) {
putDataMapRequest.getDataMap().putInt("lowTemp", lowtempforWatch);
Log.d("Test","Low Temp :"+ String.valueOf(putDataMapRequest.getDataMap().getInt("lowTemp")));
}
if (weatherIdforWatch != 0) {
putDataMapRequest.getDataMap().putInt("weatherId", weatherIdforWatch);
Log.d("Test", "Weather ID: "+String.valueOf(putDataMapRequest.getDataMap().getInt("weatherId")));
}
putDataMapRequest.setUrgent();
PutDataRequest putDataRequest = putDataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(MainActivity.googleApiClient, putDataRequest)
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult result) {
if (!result.getStatus().isSuccess()) {
System.out.println("Failure with code: " + result.getStatus().getStatusCode());
} else {
System.out.println("Success: " + result.getDataItem().getUri());
}
}
});
}
示例7: sendWearToast
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public static void sendWearToast(String msg, int length)
{
if ((googleApiClient != null) && (googleApiClient.isConnected())) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WEARABLE_TOAST_NOTIFICATON);
dataMapRequest.setUrgent();
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putInt("length", length);
dataMapRequest.getDataMap().putString("msg", msg);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
Log.e(TAG, "No connection to wearable available for toast! "+msg);
}
}
示例8: sendWearLocalToast
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public static void sendWearLocalToast(String msg, int length)
{
if ((googleApiClient != null) && (googleApiClient.isConnected())) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WEARABLE_TOAST_LOCAL_NOTIFICATON);
dataMapRequest.setUrgent();
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putInt("length", length);
dataMapRequest.getDataMap().putString("msg", msg);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
Log.e(TAG, "No connection to wearable available for toast! "+msg);
}
}
示例9: sendNotification
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
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!");
}
}
示例10: sendData
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private static boolean sendData(GoogleApiClient client, PutDataMapRequest putDataMapReq, ResultCallback<DataApi.DataItemResult> listener) {
if (client.isConnected()) {
Log.i(TAG, "update settings");
putDataMapReq.setUrgent();
PutDataRequest putDataReq = putDataMapReq.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pR =
Wearable.DataApi.putDataItem(client, putDataReq);
if (listener != null) pR.setResultCallback(listener);
return true;
}
return false;
}
示例11: onConnected
import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
@Override
public void onConnected(Bundle bundle) {
Log.d(TAG, "onConnected");
// create and send a request to update the weather on wearable
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(REQ_PATH);
putDataMapRequest.setUrgent();
putDataMapRequest.getDataMap().putInt(KEY_WEATHER_ID, mWeatherId);
putDataMapRequest.getDataMap().putDouble(KEY_TEMP_MAX, mMaxTemp);
putDataMapRequest.getDataMap().putDouble(KEY_TEMP_MIN, mMinTemp);
putDataMapRequest.getDataMap().putString(KEY_LOCATION, mLocation);
Log.d(TAG, "mLocation: " + mLocation);
Log.d(TAG, "mWeatherId: " + Integer.toString(mWeatherId));
Log.d(TAG, "mMaxTemp: " + Double.toString(mMaxTemp));
Log.d(TAG, "mMinTemp: " + Double.toString(mMinTemp));
// http://stackoverflow.com/questions/25141046/wearablelistenerservice-ondatachanged-is-not-called
// this timestamp is added to make the weather condition updates unique.
// apparently the non-unique requests are not synchronized through the wearable API.
// the non-unique requests may appear when the watch face is being selected by the user,
// and requests the weather data from the device.
putDataMapRequest.getDataMap().putLong("time", System.currentTimeMillis());
PutDataRequest request = putDataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
if (dataItemResult.getStatus().isSuccess()) {
Log.d(TAG, "Successfully sent");
} else {
Log.d(TAG, "Failed to send");
}
}
}
);
}