当前位置: 首页>>代码示例>>Java>>正文


Java DataApi.DataItemResult方法代码示例

本文整理汇总了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);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:27,代码来源:UARTConfigurationSynchronizer.java

示例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");
            }
        }

    });
}
 
开发者ID:rashikaranpuria,项目名称:ubiquitous,代码行数:23,代码来源:SunshineSyncIntentService.java

示例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;
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:13,代码来源:Message.java

示例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;
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:13,代码来源:Message.java

示例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);
}
 
开发者ID:csarron,项目名称:GmsWear,代码行数:35,代码来源:GmsWear.java

示例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());
        }
    });
}
 
开发者ID:LadyViktoria,项目名称:wearDrip,代码行数:18,代码来源:FileSender.java

示例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);
}
 
开发者ID:Parrot-Developers,项目名称:DronesWear,代码行数:18,代码来源:MainActivity.java

示例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

    }

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:16,代码来源:SendToDataLayerThread.java

示例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);
}
 
开发者ID:mladenbabic,项目名称:Advanced_Android_Development_Wear,代码行数:14,代码来源:DataManager.java

示例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());
        }
    }
}
 
开发者ID:jimmykane,项目名称:Athletica,代码行数:14,代码来源:ConfigurationHelper.java

示例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());
        }
    }
}
 
开发者ID:marcouberti,项目名称:adrenaline_watch_face,代码行数:14,代码来源:WatchFaceUtil.java

示例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);
}
 
开发者ID:csarron,项目名称:GmsWear,代码行数:12,代码来源:GmsWear.java

示例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");
    }
}
 
开发者ID:fhstp-mfg,项目名称:geowahl-android,代码行数:15,代码来源:State.java

示例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);
}
 
开发者ID:pimpimmi,项目名称:LibreAlarm,代码行数:8,代码来源:WearableApi.java


注:本文中的com.google.android.gms.wearable.DataApi.DataItemResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。