本文整理汇总了Java中com.google.android.gms.wearable.PutDataRequest.setUrgent方法的典型用法代码示例。如果您正苦于以下问题:Java PutDataRequest.setUrgent方法的具体用法?Java PutDataRequest.setUrgent怎么用?Java PutDataRequest.setUrgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.PutDataRequest
的用法示例。
在下文中一共展示了PutDataRequest.setUrgent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putConfigDataItem
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的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);
DataMap configToPut = putDataMapRequest.getDataMap();
configToPut.putAll(newConfig);
PutDataRequest putDataRequest = putDataMapRequest.asPutDataRequest();
putDataRequest.setUrgent();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest)
.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: alarmCommand
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void alarmCommand(Intent intent) {
AlarmCommand commandData = intent.getParcelableExtra(KEY_COMMAND_DATA);
LiteAlarmCommand liteAlarmCommand = new LiteAlarmCommand(commandData);
PutDataRequest putDataRequest = PutDataRequest.create(CommPaths.COMMAND_ALARM);
putDataRequest.setData(ParcelPacker.getData(liteAlarmCommand));
if (commandData.getIcon() != null) {
putDataRequest.putAsset(CommPaths.ASSET_ICON, Asset.createFromBytes(commandData.getIcon()));
}
if (commandData.getBackgroundBitmap() != null) {
putDataRequest.putAsset(CommPaths.ASSET_BACKGROUND, Asset.createFromBytes(commandData.getBackgroundBitmap()));
}
putDataRequest.setUrgent();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).await();
}
示例3: sendDataItemWithoutConnectionCheck
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Sends payload, should be only called from this class and its subclasses
*
* @param path
* @param data
*/
protected void sendDataItemWithoutConnectionCheck(DataPath path, TimeStampStorable data) {
Logger.logD(getClass().getSimpleName(), "Sending " + path);
PutDataRequest request = PutDataRequest.create(path.getPath());
final byte[] dataToSend = data.getAsBytes();
// check data size whether to send as and asset or plain data item
if (dataToSend.length >= MAX_DATA_ITEM_SIZE_B) {
request.putAsset(DataPath.DEFAULT_ASSET_KEY, Asset.createFromBytes(dataToSend));
} else {
request.setData(dataToSend);
}
if (path.isUrgent()) {
request.setUrgent();
}
PendingResult<DataApi.DataItemResult> pendingResult =
Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
示例4: stopLogger
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void stopLogger() {
File dir = getFilesDir();
File[] subFiles = dir.listFiles();
if (subFiles != null) {
for (File file : subFiles) {
if (file.getName().contains(recentIgcFileName)) {
if (debugMode) Log.d(TAG, "Now checking File " + file.getName());
Asset asset = createAssetFromTextfile(file);
PutDataMapRequest dataMap = PutDataMapRequest.create(Statics.DATAIGC + file.getName());
dataMap.getDataMap().putString("igcname", file.getName());
dataMap.getDataMap().putAsset("igcfile", asset);
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
}
}
loggerRunning = false;
loggerState.setText("");
}
示例5: updatePreferences
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void updatePreferences() {
if (debugMode) Log.d(TAG, "update Preferences");
PutDataMapRequest dataMap = PutDataMapRequest.create(Statics.DATAPREFERENCES);
dataMap.getDataMap().putString(Statics.PREFPILOTNAME, prefs.getString(Statics.PREFPILOTNAME, "na"));
dataMap.getDataMap().putString(Statics.PREFGLIDERTYPE, prefs.getString(Statics.PREFGLIDERTYPE, "na"));
dataMap.getDataMap().putString(Statics.PREFGLIDERID, prefs.getString(Statics.PREFGLIDERID, "na"));
dataMap.getDataMap().putLong(Statics.PREFLOGGERSECONDS, prefs.getLong(Statics.PREFLOGGERSECONDS, 1000));
dataMap.getDataMap().putBoolean(Statics.PREFLOGGERAUTO, prefs.getBoolean(Statics.PREFLOGGERAUTO, false));
dataMap.getDataMap().putBoolean(Statics.PREFROTATEVIEW, prefs.getBoolean(Statics.PREFROTATEVIEW, false));
dataMap.getDataMap().putBoolean(Statics.PREFSCREENON, prefs.getBoolean(Statics.PREFSCREENON, false));
dataMap.getDataMap().putString(Statics.PREFSPEEDUNIT, prefs.getString(Statics.PREFSPEEDUNIT, "km/h"));
dataMap.getDataMap().putString(Statics.PREFHEIGTHUNIT, prefs.getString(Statics.PREFHEIGTHUNIT, "m"));
dataMap.getDataMap().putString(Statics.PREFROTATEDEGREES, prefs.getString(Statics.PREFROTATEDEGREES, "0"));
dataMap.getDataMap().putBoolean(Statics.PREFUSEBTVARIO, prefs.getBoolean(Statics.PREFUSEBTVARIO, false));
dataMap.getDataMap().putString(Statics.PREFBTVARIOUNIT, prefs.getString(Statics.PREFBTVARIOUNIT, "m/s"));
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
示例6: putImageData
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Adds a {@code bitmap} image to a data item asynchronously. Caller can
* specify a {@link ResultCallback} or pass a {@code null}; if a {@code null} is passed, a
* default {@link ResultCallback} will be used (see
* {@link #putDataItem(PutDataRequest, ResultCallback)} for details).
*
* @param bitmap The bitmap to be added.
* @param path The path for the data item.
* @param key The key to be used for this item in the data map.
* @param isUrgent If {@code true}, request will be set as urgent.
* @param addTimestamp If {@code true}, adds a timestamp to the data map to always create a new
* data item even if an identical data item with the same bitmap has
* already
* been added
* @param callback The callback to be notified of the result (can be {@code null}).
*/
public void putImageData(Bitmap bitmap, String path, String key, boolean isUrgent,
boolean addTimestamp,
@Nullable ResultCallback<? super DataApi.DataItemResult> callback) {
WearUtil.assertNotNull(bitmap, "bitmap");
WearUtil.assertNotEmpty(path, "path");
WearUtil.assertNotEmpty(key, "key");
Asset imageAsset = WearUtil.toAsset(bitmap);
PutDataMapRequest dataMap = PutDataMapRequest.create(path);
dataMap.getDataMap().putAsset(key, imageAsset);
if (addTimestamp) {
dataMap.getDataMap().putLong(Constants.KEY_TIMESTAMP, new Date().getTime());
}
PutDataRequest request = dataMap.asPutDataRequest();
if (isUrgent) {
request.setUrgent();
}
putDataItem(request, callback);
}
示例7: buildWeatherRequest
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
@NonNull
private PutDataRequest buildWeatherRequest(double high, double low, Asset weatherAsset) {
PutDataMapRequest weatherDataMapRequest = PutDataMapRequest.create(PATH_DATA_WEATHER + System.currentTimeMillis());
DataMap weatherRequestDataMap = weatherDataMapRequest.getDataMap();
weatherRequestDataMap.putDouble("high", high);
weatherRequestDataMap.putDouble("low", low);
weatherRequestDataMap.putAsset("icon", weatherAsset);
PutDataRequest weatherRequest = weatherDataMapRequest.asPutDataRequest();
weatherRequest.setUrgent();
return weatherRequest;
}
示例8: reportQueueChanged
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
@Override
public void reportQueueChanged(@Nullable final List<Media> queue) {
if (mGoogleApiClient.isConnected() && queue != null && !queue.isEmpty()) {
final WearPlaybackData.Media[] wMedias = new WearPlaybackData.Media[queue.size()];
int i = 0;
for (final Media media : queue) {
wMedias[i] = toWearableMedia(media, 0);
i++;
}
final PutDataRequest request;
try {
request = PutDataRequest.create(DataPaths.Paths.QUEUE);
final WearPlaybackData.Queue wQueue = new WearPlaybackData.Queue();
wQueue.media = wMedias;
request.setData(ProtoUtils.toByteArray(wQueue));
} catch (IOException e) {
Log.w(TAG, e);
return;
}
request.setUrgent();
Wearable.DataApi.putDataItem(mGoogleApiClient, request).await();
}
}
示例9: handleExpressions
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void handleExpressions(final String path, final String expression, final String id) {
if(validateConnection()) {
PutDataMapRequest dataMap = PutDataMapRequest.create(path);
dataMap.getDataMap().putString(DataMapKeys.EXPRESSION_ID, id);
dataMap.getDataMap().putString(DataMapKeys.EXPRESSION, expression);
dataMap.getDataMap().putLong("Time",System.currentTimeMillis());
PutDataRequest putDataRequest = dataMap.asPutDataRequest();
putDataRequest = putDataRequest.setUrgent();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
Log.d(TAG, "Sending new expession ++++++++" + path +" " + id + ": " + dataItemResult.getStatus().isSuccess());
}
});
}
}
示例10: handleSensors
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void handleSensors(final String path, final int sensorID, final int acuracy) {
if(validateConnection()) {
PutDataMapRequest dataMap = PutDataMapRequest.create(path);
dataMap.getDataMap().putInt(SensorConstants.SENSOR_ID, sensorID);
dataMap.getDataMap().putInt(SensorConstants.ACCURACY, acuracy);
dataMap.getDataMap().putLong("Time",System.currentTimeMillis());
PutDataRequest putDataRequest = dataMap.asPutDataRequest();
putDataRequest = putDataRequest.setUrgent();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
Log.d(TAG, "Sending new sensor ++++++++" + path +" " + sensorID + ": " + dataItemResult.getStatus().isSuccess());
}
});
}
}
示例11: addLocationEntry
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
private void addLocationEntry(double latitude, double longitude) {
if (!mGpsPermissionApproved || !mGoogleApiClient.isConnected()) {
return;
}
mCalendar.setTimeInMillis(System.currentTimeMillis());
LocationEntry entry = new LocationEntry(mCalendar, latitude, longitude);
String path = Constants.PATH + "/" + mCalendar.getTimeInMillis();
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);
putDataMapRequest.getDataMap().putDouble(Constants.KEY_LATITUDE, entry.latitude);
putDataMapRequest.getDataMap().putDouble(Constants.KEY_LONGITUDE, entry.longitude);
putDataMapRequest.getDataMap()
.putLong(Constants.KEY_TIME, entry.calendar.getTimeInMillis());
PutDataRequest request = putDataMapRequest.asPutDataRequest();
request.setUrgent();
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
if (!dataItemResult.getStatus().isSuccess()) {
Log.e(TAG, "AddPoint:onClick(): Failed to set the data, "
+ "status: " + dataItemResult.getStatus()
.getStatusCode());
}
}
});
}
示例12: sendPhoto
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Sends the asset that was created from the photo we took by adding it to the Data Item store.
*/
private void sendPhoto(Asset asset) {
PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH);
dataMap.getDataMap().putAsset(IMAGE_KEY, asset);
dataMap.getDataMap().putLong("time", new Date().getTime());
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
dataItemTask.addOnSuccessListener(new OnSuccessListener<DataItem>() {
@Override
public void onSuccess(DataItem dataItem) {
LOGD(TAG, "Sending image was successful: " + dataItem);
}
});
}
示例13: sendData
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Sends the data, not this is a broadcast, so we will get the message as well.
*/
private void sendData(String message) {
PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
dataMap.getDataMap().putString("message", message);
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
dataItemTask
.addOnSuccessListener(new OnSuccessListener<DataItem>() {
@Override
public void onSuccess(DataItem dataItem) {
Log.d(TAG, "Sending message was successful: " + dataItem);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(TAG, "Sending message failed: " + e);
}
})
;
}
示例14: sendData
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Sends the data. Since it specify a client, everyone who is listening to the path, will
* get the data.
*/
private void sendData(String message) {
PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
dataMap.getDataMap().putString("message", message);
PutDataRequest request = dataMap.asPutDataRequest();
request.setUrgent();
Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
dataItemTask
.addOnSuccessListener(new OnSuccessListener<DataItem>() {
@Override
public void onSuccess(DataItem dataItem) {
Log.d(TAG, "Sending message was successful: " + dataItem);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e(TAG, "Sending message failed: " + e);
}
})
;
}
示例15: sendData
import com.google.android.gms.wearable.PutDataRequest; //导入方法依赖的package包/类
/**
* Send the sensors data to the phone
* @param dataMapRequest data map to send
* @return send result
*/
@Override
public PendingResult<DataApi.DataItemResult> sendData(PutDataMapRequest dataMapRequest) {
PutDataRequest dataRequest = dataMapRequest.asPutDataRequest();
dataRequest.setUrgent();
return Wearable.DataApi.putDataItem(apiClient, dataRequest);
}
开发者ID:ibm-wearables-sdk-for-mobile,项目名称:ibm-wearables-android-sdk,代码行数:13,代码来源:MessageReceiverService.java