當前位置: 首頁>>代碼示例>>Java>>正文


Java PutDataRequest.putAsset方法代碼示例

本文整理匯總了Java中com.google.android.gms.wearable.PutDataRequest.putAsset方法的典型用法代碼示例。如果您正苦於以下問題:Java PutDataRequest.putAsset方法的具體用法?Java PutDataRequest.putAsset怎麽用?Java PutDataRequest.putAsset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.wearable.PutDataRequest的用法示例。


在下文中一共展示了PutDataRequest.putAsset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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();
}
 
開發者ID:matejdro,項目名稱:WearVibrationCenter,代碼行數:20,代碼來源:WatchCommander.java

示例2: 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);
}
 
開發者ID:asamm,項目名稱:locus-addon-wearables,代碼行數:23,代碼來源:LocusWearCommService.java


注:本文中的com.google.android.gms.wearable.PutDataRequest.putAsset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。