當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。