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


Java PutDataMapRequest類代碼示例

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


PutDataMapRequest類屬於com.google.android.gms.wearable包,在下文中一共展示了PutDataMapRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onConfigurationAddedOrEdited

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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: sendNextGestureData

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
/**
 * Create new Data Request and send it to the phone
 */
private void sendNextGestureData() {
    PutDataMapRequest dataMapRequest = getNewSensorsDataMapRequest();
    DataMap dataMap = dataMapRequest.getDataMap();

    List<GestureDataHolder.EventData> nextAccelerometerData = gestureDataHolder.pollNextAccelerometerData();
    if (nextAccelerometerData.size() > 0){
        dataMap.putDataMapArrayList("accelerometer", convertEventsToDataMapList(nextAccelerometerData));
    }

    List<GestureDataHolder.EventData> nextGyroscopeData = gestureDataHolder.pollNextGyroscopeData();
    if (nextGyroscopeData.size() > 0){
        dataMap.putDataMapArrayList("gyroscope", convertEventsToDataMapList(nextGyroscopeData));
    }

    dataSender.sendData(dataMapRequest);
}
 
開發者ID:ibm-wearables-sdk-for-mobile,項目名稱:ibm-wearables-android-sdk,代碼行數:20,代碼來源:DataManager.java

示例3: putConfigDataItem

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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());
                    }
                }
            });
}
 
開發者ID:marcouberti,項目名稱:adrenaline_watch_face,代碼行數:21,代碼來源:WatchFaceUtil.java

示例4: putConfigDataItem

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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);
    putDataMapRequest.setUrgent();
    DataMap configToPut = putDataMapRequest.getDataMap();
    configToPut.putAll(newConfig);
    Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
            .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());
                    }
                }
            });
}
 
開發者ID:passiondroid,項目名稱:SunshineApp,代碼行數:20,代碼來源:DigitalWatchFaceUtil.java

示例5: sendBotList

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
private void sendBotList() {
    PutDataMapRequest request = PutDataMapRequest.create(WearMessages.MESSAGE_BOT_LIST);
    DataMap map = request.getDataMap();

    HombotDataOpenHelper dataHelper = new HombotDataOpenHelper(this);
    final SQLiteDatabase db = dataHelper.getReadableDatabase();
    Cursor botCursor = db.query(HombotDataContract.BotEntry.TABLE_NAME, new String[]{HombotDataContract.BotEntry._ID, HombotDataContract.BotEntry.COLUMN_NAME_NAME, HombotDataContract.BotEntry.COLUMN_NAME_ADDRESS}, null, new String[0], null, null, HombotDataContract.BotEntry.COLUMN_NAME_NAME);

    ArrayList<DataMap> botList = new ArrayList<>();

    for (int i = 0; i < botCursor.getCount(); i++) {
        botCursor.moveToPosition(i);
        DataMap botMap = new DataMap();
        botMap.putString(WearMessages.MAPENTRY_BOT_NAME, botCursor.getString(botCursor.getColumnIndexOrThrow(HombotDataContract.BotEntry.COLUMN_NAME_NAME)));
        botMap.putString(WearMessages.MAPENTRY_BOT_ADDRESS, botCursor.getString(botCursor.getColumnIndexOrThrow(HombotDataContract.BotEntry.COLUMN_NAME_ADDRESS)));
        botMap.putLong(WearMessages.MAPENTRY_BOT_ID, botCursor.getLong(botCursor.getColumnIndexOrThrow(HombotDataContract.BotEntry.COLUMN_NAME_ADDRESS)));
        botList.add(botMap);
    }

    map.putLong("HASH", System.currentTimeMillis()); // NEED TO DO THIS BECAUSE OTHERWHISE DATA DIT NOT CHANGE AND WEAR EVENT DOES NOT TRIGGER
    map.putDataMapArrayList(WearMessages.MAPENTRY_BOT_LIST, botList);
    Wearable.DataApi.putDataItem(mGoogleApiClient, request.asPutDataRequest());
}
 
開發者ID:rampage128,項目名稱:hombot-control,代碼行數:24,代碼來源:WearListenerService.java

示例6: sendData

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
private void sendData(ArrayList<Story> storiesToSend) {
    if(storiesToSend == null || storiesToSend.size() == 0){
        return;
    }
    PutDataMapRequest dataMap = PutDataMapRequest.create(Tools.WEAR_PATH);
    DataMap dataMapToPut = dataMap.getDataMap();
    JSONArray contentList = new JSONArray();
    for(Story story : storiesToSend){
        contentList.put(story.toJSONObject());
    }

    dataMapToPut.putString(Tools.WEAR_KEY, contentList.toString());
    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) {
            mGoogleAppiClient.disconnect();
        }
    });

}
 
開發者ID:tajchert,項目名稱:SpritzerWear,代碼行數:23,代碼來源:StorySender.java

示例7: getUpdateRequest

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
/**
 * Obtain a {@link PutDataRequest} to update a league's current state.
 *
 * @param account the account which owns the team competing in the league
 * @param league a proto describing the league
 * @param matchup a proto describing the account's team's current matchup
 * @param logo an Asset containing the user's logo image. The image should be square with size
 *             {@link com.jeffpdavidson.fantasywear.common.R.dimen#logo_size}.
 * @param opponentLogo an Asset containing the user's opponent's logo image. The image should be
 *                     square with size
 *                     {@link com.jeffpdavidson.fantasywear.common.R.dimen#logo_size}.
 * @param forceUpdate if true, will ensure that listening devices see the update even if no
 *                    fields have changed since the last update. Use conservatively as this will
 */
public static PutDataRequest getUpdateRequest(Account account, League league, Matchup matchup,
        Asset logo, Asset opponentLogo, boolean forceUpdate) {
    PutDataMapRequest request =
            PutDataMapRequest.create(getLeagueUri(account, league).toString());
    DataMap map = request.getDataMap();
    map.putInt(KEY_APP_VERSION, BuildConfig.VERSION_CODE);
    map.putString(KEY_MATCHUP, WireUtil.encodeToString(matchup));
    map.putAsset(KEY_LOGO, logo);
    map.putAsset(KEY_OPPONENT_LOGO, opponentLogo);
    if (forceUpdate) {
        // Play services suppresses updates if the payload exactly matches the last one, so when
        // forcing an update, include the current time to guarantee a unique payload.
        map.putLong(KEY_TIMESTAMP, System.currentTimeMillis());
    }
    return request.asPutDataRequest();
}
 
開發者ID:jpd236,項目名稱:fantasywear,代碼行數:31,代碼來源:LeagueData.java

示例8: insert

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
/**
 * This method is called when someone wants to insert something
 * into our content provider.
 */
@Override
public Uri insert(Uri uri, ContentValues values) {
    // you can't choose your own task id
    if( values.containsKey(COLUMN_TASKID))
        throw new UnsupportedOperationException();

    long id = db.insertOrThrow(DATABASE_TABLE, null,
            values);
    getContext().getContentResolver().notifyChange(uri, null);

    // Save to google Play for wearable support
    PutDataMapRequest dataMap = PutDataMapRequest.create(
            PLAY_BASE_URL + "/" + id);
    DataMap map = dataMap.getDataMap();
    map.putLong(COLUMN_TASKID, id);
    map.putString(COLUMN_TITLE, values.getAsString(COLUMN_TITLE));
    map.putLong(COLUMN_DATE_TIME, values.getAsLong(COLUMN_DATE_TIME));
    map.putString(COLUMN_NOTES, values.getAsString(COLUMN_NOTES));
    PutDataRequest request = dataMap.asPutDataRequest();
    Wearable.DataApi.putDataItem(googleApiClient, request);


    return ContentUris.withAppendedId(uri, id);
}
 
開發者ID:emmby,項目名稱:easy-a,代碼行數:29,代碼來源:TaskProvider.java

示例9: putNotification

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
@WorkerThread
public void putNotification(String title, String textShort, String textLong, @Nullable Bitmap photo, Uri contactUri, @Nullable String phoneNumber) {
    Log.d();
    // First remove any old notification
    Wearable.DataApi.deleteDataItems(mGoogleApiClient, createUri(PATH_NOTIFICATION)).await();

    // Create new notification
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_NOTIFICATION);

    DataMap dataMap = putDataMapRequest.getDataMap();
    dataMap.putString(EXTRA_TITLE, title);
    dataMap.putString(EXTRA_TEXT_SHORT, textShort);
    dataMap.putString(EXTRA_TEXT_LONG, textLong);
    if (photo != null) dataMap.putAsset(EXTRA_PHOTO, createAssetFromBitmap(photo));
    byte[] contactUriBytes = ParcelableUtil.parcel(contactUri);
    dataMap.putByteArray(EXTRA_CONTACT_URI, contactUriBytes);
    if (phoneNumber != null) dataMap.putString(EXTRA_PHONE_NUMBER, phoneNumber);

    PutDataRequest request = putDataMapRequest.asPutDataRequest();
    Wearable.DataApi.putDataItem(mGoogleApiClient, request).await();
}
 
開發者ID:BoD,項目名稱:DoorCodeNotifier,代碼行數:22,代碼來源:WearHelper.java

示例10: onConfigurationAddedOrEdited

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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 (!hasConnectedApi())
		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:NordicSemiconductor,項目名稱:Android-nRF-Toolbox,代碼行數:27,代碼來源:UARTConfigurationSynchronizer.java

示例11: buildDataRequest

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
/**
 * Builds a {@link com.google.android.gms.wearable.PutDataRequest} which holds a JSON
 * representation of the feedback collected.
 */
private PutDataRequest buildDataRequest() throws JSONException {
    PutDataMapRequest putDataMapRequest = PutDataMapRequest
            .create(HomeListenerService.PATH_RESPONSE);
    DataMap dataMap = putDataMapRequest.getDataMap();

    JSONArray jsonArray = new JSONArray();
    if (!responses.isEmpty()) {
        JSONObject sessionObj = new JSONObject();
        sessionObj.put("s", mSessionId);
        jsonArray.put(0, sessionObj);
        int i = 1;
        for (Integer key : responses.keySet()) {
            JSONObject obj = new JSONObject();
            obj.put("q", key);
            obj.put("a", responses.get(key));
            jsonArray.put(i++, obj);
        }
    }
    String response = jsonArray.toString();
    LOGD(TAG, "JSON representation of the response: " + response);
    dataMap.putString("response", response);
    return putDataMapRequest.asPutDataRequest();
}
 
開發者ID:The-WebOps-Club,項目名稱:saarang-iosched,代碼行數:28,代碼來源:PagerActivity.java

示例12: updateWearWeather

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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

示例13: putConfigDataItem

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig, String path) {
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);
    DataMap configToPut = putDataMapRequest.getDataMap();
    configToPut.putAll(newConfig);
    Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
            .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());
                    }
                }
            });
}
 
開發者ID:mladenbabic,項目名稱:Advanced_Android_Development_Wear,代碼行數:15,代碼來源:DigitalWatchFaceUtil.java

示例14: sendHeartRateData

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的package包/類
/**
 * Create next data to send of the hear rate
 * @param event sensor event
 */
private void sendHeartRateData(SensorEvent event){
    PutDataMapRequest dataMapRequest = getNewSensorsDataMapRequest();

    DataMap dataMap = dataMapRequest.getDataMap();
    dataMap.putFloat("heartrate",event.values[0]);

    dataSender.sendData(dataMapRequest);
}
 
開發者ID:ibm-wearables-sdk-for-mobile,項目名稱:ibm-wearables-android-sdk,代碼行數:13,代碼來源:DataManager.java

示例15: putConfigDataItem

import com.google.android.gms.wearable.PutDataMapRequest; //導入依賴的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);
    putDataMapRequest.setUrgent();
    DataMap configToPut = putDataMapRequest.getDataMap();
    configToPut.putAll(newConfig);
    Wearable.DataApi.putDataItem(googleApiClient, putDataMapRequest.asPutDataRequest())
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
                    Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus());
                }
            });
}
 
開發者ID:jimmykane,項目名稱:Athletica,代碼行數:18,代碼來源:ConfigurationHelper.java


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