本文整理汇总了Java中com.google.android.gms.wearable.DataApi.DataItemResult方法的典型用法代码示例。如果您正苦于以下问题:Java DataApi.DataItemResult方法的具体用法?Java DataApi.DataItemResult怎么用?Java DataApi.DataItemResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataApi
的用法示例。
在下文中一共展示了DataApi.DataItemResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConfigurationAddedOrEdited
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
/**
* Synchronizes the UART configurations between handheld and wearables.
* Call this when configuration has been created or altered.
* @return pending result
*/
public PendingResult<DataApi.DataItemResult> onConfigurationAddedOrEdited(final long id, final UartConfiguration configuration) {
if (mGoogleApiClient == null || !mGoogleApiClient.isConnected())
return null;
final PutDataMapRequest mapRequest = PutDataMapRequest.create(Constants.UART.CONFIGURATIONS + "/" + id);
final DataMap map = mapRequest.getDataMap();
map.putString(Constants.UART.Configuration.NAME, configuration.getName());
final ArrayList<DataMap> commands = new ArrayList<>(UartConfiguration.COMMANDS_COUNT);
for (Command command : configuration.getCommands()) {
if (command != null && command.isActive()) {
final DataMap item = new DataMap();
item.putInt(Constants.UART.Configuration.Command.ICON_ID, command.getIconIndex());
item.putString(Constants.UART.Configuration.Command.MESSAGE, command.getCommand());
item.putInt(Constants.UART.Configuration.Command.EOL, command.getEolIndex());
commands.add(item);
}
}
map.putDataMapArrayList(Constants.UART.Configuration.COMMANDS, commands);
final PutDataRequest request = mapRequest.asPutDataRequest();
return Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
示例2: updateWearWeather
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
private void updateWearWeather(int weather_id, double high_temp, double low_temp){
PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(WEATHER_PATH).setUrgent();
putDataMapRequest.getDataMap().putInt(WEATHER_ID, weather_id);
Log.d(LOG_TAG, "value of weather put : "+weather_id);
putDataMapRequest.getDataMap().putDouble(HIGH_TEMP, high_temp);
putDataMapRequest.getDataMap().putDouble(LOW_TEMP, low_temp);
PutDataRequest putDataRequest = putDataMapRequest.asPutDataRequest().setUrgent();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mWearClient, putDataRequest);
pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
if (dataItemResult.getStatus().isSuccess()) {
Log.d(LOG_TAG, "Data item set: " + dataItemResult.getDataItem().getUri());
} else {
Log.d(LOG_TAG, "Error in sending data to watch");
}
}
});
}
示例3: sendActionTypeMessage
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
public static PendingResult<DataApi.DataItemResult> sendActionTypeMessage(int actionType, GoogleApiClient googleApiClient) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_TYPE_PATH);
DataMap dataMap = dataMapRequest.getDataMap();
//Data set
dataMap.putInt(VALUE_STR, actionType);
// Data Push
PutDataRequest request = dataMapRequest.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(googleApiClient, request);
return pendingResult;
}
示例4: sendInteractionTypeMessage
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
public static PendingResult<DataApi.DataItemResult> sendInteractionTypeMessage(int interactionBitfield, GoogleApiClient googleApiClient) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(INTERACTION_TYPE_PATH);
DataMap dataMap = dataMapRequest.getDataMap();
//Data set
dataMap.putInt(VALUE_STR, interactionBitfield);
// Data Push
PutDataRequest request = dataMapRequest.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(googleApiClient, request);
return pendingResult;
}
示例5: putImageData
import com.google.android.gms.wearable.DataApi; //导入方法依赖的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);
}
示例6: sendData
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
private void sendData(Asset asset) {
if (asset == null) {
return;
}
PutDataMapRequest dataMap = PutDataMapRequest.create(WEAR_PATH);
byte[] arr = asset.getData();
dataMap.getDataMap().putByteArray(DATA_ASSET_FILE, arr);
dataMap.getDataMap().putLong("timestamp", Calendar.getInstance().getTimeInMillis());
PutDataRequest request = dataMap.asPutDataRequest();
PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleAppiClient, request);
pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
Log.d(TAG, "onResult result:" + dataItemResult.getStatus());
}
});
}
示例7: onButtonClicked
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
private void onButtonClicked()
{
PendingResult<DataApi.DataItemResult> pendingResult = Message.sendActionMessage(mGoogleApiClient);
pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
Message.emptyActionMessage(mGoogleApiClient);
}
});
Intent intent = new Intent(this, ConfirmationActivity.class);
intent.putExtra(ConfirmationActivity.EXTRA_ANIMATION_TYPE,
ConfirmationActivity.SUCCESS_ANIMATION);
intent.putExtra(ConfirmationActivity.EXTRA_MESSAGE,
getString(R.string.action_sent));
startActivity(intent);
}
示例8: run
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
@Override
public void run() {
// Construct a DataRequest and send over the data layer
PutDataMapRequest putDMR = PutDataMapRequest.create(path);
putDMR.getDataMap().putAll(dataMap);
PutDataRequest request = putDMR.asPutDataRequest();
DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleClient, request).await();
if (result.getStatus().isSuccess()) {
} else {
// Log an error
}
}
示例9: syncDataMap
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
public void syncDataMap(GoogleApiClient mGoogleApiClient, DataMap dataMap,
String path,
ResultCallback<DataApi.DataItemResult> resultCallback){
PutDataMapRequest putdatamaprequest = PutDataMapRequest.create(path);
putdatamaprequest.getDataMap().putAll(dataMap);
PutDataRequest request = putdatamaprequest.asPutDataRequest();
if (!mGoogleApiClient.isConnected()) {
return;
}
Log.d(TAG, "DataMap " + dataMap + " sending to " + path);
Wearable.DataApi.putDataItem(mGoogleApiClient, request) .setResultCallback(resultCallback);
}
示例10: sendData
import com.google.android.gms.wearable.DataApi; //导入方法依赖的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
示例11: onResult
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
@Override
public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
if (dataItemResult.getStatus().isSuccess()) {
if (dataItemResult.getDataItem() != null) {
DataItem configDataItem = dataItemResult.getDataItem();
DataMapItem dataMapItem = DataMapItem.fromDataItem(configDataItem);
DataMap config = dataMapItem.getDataMap();
mCallback.onConfigDataMapFetched(config);
} else {
mCallback.onConfigDataMapFetched(new DataMap());
}
}
}
示例12: onResult
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
@Override
public void onResult(DataApi.DataItemResult dataItemResult) {
if (dataItemResult.getStatus().isSuccess()) {
if (dataItemResult.getDataItem() != null) {
DataItem configDataItem = dataItemResult.getDataItem();
DataMapItem dataMapItem = DataMapItem.fromDataItem(configDataItem);
DataMap config = dataMapItem.getDataMap();
mCallback.onConfigDataMapFetched(config);
} else {
mCallback.onConfigDataMapFetched(new DataMap());
}
}
}
示例13: getDataItemSynchronous
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
/**
* Retrieves data items with the given {@code dataItemUri} <b>synchronously</b>.
* This should be called on non-UI threads. A {@code timeoutInMillis} is required to specify
* the maximum length of time, in milliseconds, that the thread should be blocked.
*/
public DataApi.DataItemResult getDataItemSynchronous(Uri dataItemUri, long timeoutInMillis) {
assertApiConnectivity();
WearUtil.assertNonUiThread();
return Wearable.DataApi.getDataItem(mGoogleApiClient, dataItemUri).await(
timeoutInMillis, TimeUnit.MILLISECONDS);
}
示例14: run
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
public void run() {
// Construct a DataRequest and send over the data layer
PutDataMapRequest putDMR = PutDataMapRequest.create(path);
putDMR.getDataMap().putAll(dataMap);
PutDataRequest request = putDMR.asPutDataRequest();
DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleClient, request).await();
if (result.getStatus().isSuccess()) {
Log.v("myTag", "DataMap: " + dataMap + " sent successfully to data layer ");
}
else {
// Log an error
Log.v("myTag", "ERROR: failed to send DataMap to data layer");
}
}
示例15: sendData
import com.google.android.gms.wearable.DataApi; //导入方法依赖的package包/类
public static boolean sendData(GoogleApiClient client, String command, HashMap<String, String> pairs, ResultCallback<DataApi.DataItemResult> listener) {
PutDataMapRequest putDataMapReq = PutDataMapRequest.create(command);
for (String key : pairs.keySet()) {
putDataMapReq.getDataMap().putString(key, pairs.get(key));
}
return sendData(client, putDataMapReq, listener);
}