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


Java PutDataMapRequest.asPutDataRequest方法代碼示例

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


在下文中一共展示了PutDataMapRequest.asPutDataRequest方法的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: 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

示例3: sendDataReceived

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void sendDataReceived(String path, String notification, long timeOfLastEntry, String type, long watch_syncLogsRequested) {//KS
    Log.d(TAG, "sendDataReceived timeOfLastEntry=" + JoH.dateTimeText(timeOfLastEntry) + " Path=" + path);
    forceGoogleApiConnect();
    if (googleApiClient.isConnected()) {
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path);
        dataMapRequest.setUrgent();
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        dataMapRequest.getDataMap().putLong("timeOfLastEntry", timeOfLastEntry);
        dataMapRequest.getDataMap().putLong("syncLogsRequested", watch_syncLogsRequested);
        dataMapRequest.getDataMap().putString("type", type);
        dataMapRequest.getDataMap().putString("msg", notification);
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
    } else {
        Log.e(TAG, "sendDataReceived No connection to wearable available!");
    }
}
 
開發者ID:jamorham,項目名稱:xDrip-plus,代碼行數:18,代碼來源:WatchUpdaterService.java

示例4: sendTrackingStatusDataMap

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
/**
 * Send the current status of the step count tracking weather it is running or not. This message
 * is important and we should have guarantee of delivery to maintain the state of tracking status
 * on the phone. That is why we are using DataMap to communicate. So, if the phone is not connected
 * the message won't get lost. As soon as the phone connects, this status message will pass to the
 * phone application.
 *
 * @param isTracking true if the tracking is running
 */
private void sendTrackingStatusDataMap(boolean isTracking) {
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create(STEP_TRACKING_STATUS_PATH);

    dataMapRequest.getDataMap().putBoolean("status", isTracking);
    dataMapRequest.getDataMap().putLong("status-time", System.currentTimeMillis());

    PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
    Wearable.DataApi.putDataItem(mGoogleApiClient, putDataRequest)
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
                    //check if the message is delivered?
                    //If the status is failed, that means that the currently device is
                    //not connected. The data will get deliver when phone gets connected to the watch.
                    Log.d("Data saving", dataItemResult.getStatus().isSuccess() ? "Success" : "Failed");
                }
            });

}
 
開發者ID:kevalpatel2106,項目名稱:android-samples,代碼行數:29,代碼來源:TrackActivity.java

示例5: notifyWear

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void notifyWear(String newBgColor) {
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create("/bg_change");

    dataMapRequest.getDataMap().putString("new_color", newBgColor);

    PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
    Wearable.DataApi.putDataItem(mGoogleApiClient, putDataRequest)
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(@NonNull DataApi.DataItemResult dataItemResult) {
                    //check if the message is delivered?
                    //If the status is failed, that means that the currently device is
                    //not connected. The data will get deliver when phone gets connected to the watch.
                    Log.d("Data saving", dataItemResult.getStatus().isSuccess() ? "Success" : "Failed");
                }
            });
}
 
開發者ID:kevalpatel2106,項目名稱:android-samples,代碼行數:18,代碼來源:WatchFaceConfigActivity.java

示例6: sendTreatment

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public static void sendTreatment(double carbs, double insulin, double bloodtest, double timeoffset, String timestring) {
    if ((googleApiClient != null) && (googleApiClient.isConnected())) {
        PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WEARABLE_TREATMENT_PAYLOAD);
        //unique content
        dataMapRequest.setUrgent();
        dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
        dataMapRequest.getDataMap().putDouble("carbs", carbs);
        dataMapRequest.getDataMap().putDouble("insulin", insulin);
        dataMapRequest.getDataMap().putDouble("bloodtest", bloodtest);
        dataMapRequest.getDataMap().putDouble("timeoffset", timeoffset);
        dataMapRequest.getDataMap().putString("timestring", timestring);
        dataMapRequest.getDataMap().putBoolean("ismgdl", doMgdl(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext())));
        PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
    } else {
        Log.e(TAG, "No connection to wearable available for send treatment!");
    }
}
 
開發者ID:jamorham,項目名稱:xDrip-plus,代碼行數:19,代碼來源:WatchUpdaterService.java

示例7: sendTodayForecast

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void sendTodayForecast(double maxTemp, double minTemp, int weatherId) {

        PutDataMapRequest dataMap = PutDataMapRequest.create(FORECAST_PATH).setUrgent();
        String lowString = Utility.formatTemperature(getContext(), minTemp);
        String highString = Utility.formatTemperature(getContext(), maxTemp);
        dataMap.getDataMap().putString(MAX_TEMP_KEY, highString);
        dataMap.getDataMap().putString(MIN_TEMP_KEY, lowString);

        int artResource = Utility.getArtResourceForWeatherCondition(weatherId);
        Asset weatherIcon = Utility.toAsset(artResource, getContext());
        dataMap.getDataMap().putAsset(WEATHER_ICON_KEY, weatherIcon);
        dataMap.getDataMap().putLong(TIMESTAMP_KEY, System.currentTimeMillis());
        PutDataRequest request = dataMap.asPutDataRequest();

        Wearable.DataApi.putDataItem(mGoogleApiClient, request)
                .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                    @Override
                    public void onResult(DataApi.DataItemResult dataItemResult) {
                        if (!dataItemResult.getStatus().isSuccess()) {
                            Log.e(LOG_TAG, "ERROR: failed to putDataItem, status code: "
                                    + dataItemResult.getStatus().getStatusCode());
                        }
                    }
                });
    }
 
開發者ID:jainkamini,項目名稱:Sunshinewear,代碼行數:26,代碼來源:SunshineSyncAdapter.java

示例8: updatePreferences

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void updatePreferences() {
    if (debugMode) Log.d(TAG, "update Preferences");
    PutDataMapRequest dataMap = PutDataMapRequest.create(Statics.DATAPREFERENCES);
    dataMap.getDataMap().putString(Statics.PREFPILOTNAME, prefs.getString(Statics.PREFPILOTNAME, "na"));
    dataMap.getDataMap().putString(Statics.PREFGLIDERTYPE, prefs.getString(Statics.PREFGLIDERTYPE, "na"));
    dataMap.getDataMap().putString(Statics.PREFGLIDERID, prefs.getString(Statics.PREFGLIDERID, "na"));
    dataMap.getDataMap().putLong(Statics.PREFLOGGERSECONDS, prefs.getLong(Statics.PREFLOGGERSECONDS, 1000));
    dataMap.getDataMap().putBoolean(Statics.PREFLOGGERAUTO, prefs.getBoolean(Statics.PREFLOGGERAUTO, false));
    dataMap.getDataMap().putBoolean(Statics.PREFROTATEVIEW, prefs.getBoolean(Statics.PREFROTATEVIEW, false));
    dataMap.getDataMap().putBoolean(Statics.PREFSCREENON, prefs.getBoolean(Statics.PREFSCREENON, false));
    dataMap.getDataMap().putString(Statics.PREFSPEEDUNIT, prefs.getString(Statics.PREFSPEEDUNIT, "km/h"));
    dataMap.getDataMap().putString(Statics.PREFHEIGTHUNIT, prefs.getString(Statics.PREFHEIGTHUNIT, "m"));
    dataMap.getDataMap().putString(Statics.PREFROTATEDEGREES, prefs.getString(Statics.PREFROTATEDEGREES, "0"));
    dataMap.getDataMap().putBoolean(Statics.PREFUSEBTVARIO, prefs.getBoolean(Statics.PREFUSEBTVARIO, false));
    dataMap.getDataMap().putString(Statics.PREFBTVARIOUNIT, prefs.getString(Statics.PREFBTVARIOUNIT, "m/s"));
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();
    Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:20,代碼來源:MainActivity.java

示例9: sendInteractionTypeMessage

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

示例10: sendState

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public void sendState(boolean state) {
    final PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(Const.LOCK_PATH);
    Date d = new Date();
    putDataMapRequest.getDataMap().putLong("timestamp", d.getTime());
    putDataMapRequest.getDataMap().putBoolean("state", state);

    if (!mGoogleApiClient.isConnected())
        throw new RuntimeException("Cannot send data item when connection is not ready");
    Log.d(Const.TAG_ACTIVITY, "Preparing data item for send, isConnected=" + mGoogleApiClient.isConnected());
    final PutDataRequest request = putDataMapRequest.asPutDataRequest();
    Wearable.DataApi.putDataItem(mGoogleApiClient, request)
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(DataApi.DataItemResult dataItemResult) {
                    if (!dataItemResult.getStatus().isSuccess()) {
                        Log.e(Const.TAG_ACTIVITY, "Failed to send data map item for " + Const.LOCK_PATH + " status: " + dataItemResult.getStatus().getStatusCode());
                    } else {
                        Log.d(Const.TAG_ACTIVITY, "Sent data map item for " + Const.LOCK_PATH + " " + putDataMapRequest);
                    }
                }
            });
}
 
開發者ID:google,項目名稱:wear-displaylock,代碼行數:23,代碼來源:MainActivity.java

示例11: sendWeatherIconToDevices

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private static void sendWeatherIconToDevices(Bitmap weatherIcon) {
        PutDataMapRequest dataMap = PutDataMapRequest.create("/image");
        dataMap.getDataMap().putAsset(TodayWeatherAsyncTask.KEY_WEATHER_ICON, Utility.createAssetFromBitmap(weatherIcon));
        PutDataRequest request = dataMap.asPutDataRequest();
        PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, request);
        pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
            @Override
            public void onResult(DataApi.DataItemResult dataItemResult) {
                // something
            }
        });
//        Asset asset =  Utility.createAssetFromBitmap(weatherIcon);
//        PutDataRequest request = PutDataRequest.create("/image");
//        request.putAsset(TodayWeatherAsyncTask.KEY_WEATHER_ICON, asset);
//        Wearable.DataApi.putDataItem(mGoogleApiClient, request);
    }
 
開發者ID:PedroCarrillo,項目名稱:sunshine-wear-watchface,代碼行數:17,代碼來源:WeatherWearableListener.java

示例12: newNotify

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
public void newNotify(String tickerText, String message)
{
    notifier.tickerText = tickerText;
    contentView.setTextViewText(R.id.message, message);
    notifyMan.notify(NID, notifier);

    //Send this whenever we redo our notification, that way title is same on wear
    if (client.isConnected()) {
        //Set our path of our request
        PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH);

        // Add data to the request
        putDataMapRequest.getDataMap().putString(KEY,
                tickerText);
        putDataMapRequest.getDataMap().
                putLong("time", new Date().getTime());

        //request our request
        PutDataRequest request = putDataMapRequest.asPutDataRequest();

        //Send to wearable
        Wearable.DataApi.putDataItem(client, request);
    }
}
 
開發者ID:torch2424,項目名稱:Feather,代碼行數:25,代碼來源:NotificationPanel.java

示例13: handleSensors

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void handleSensors(final String path, final int sensorID, final int acuracy) {
    if(validateConnection()) {
        PutDataMapRequest dataMap = PutDataMapRequest.create(path);

        dataMap.getDataMap().putInt(SensorConstants.SENSOR_ID, sensorID);
        dataMap.getDataMap().putInt(SensorConstants.ACCURACY, acuracy);
        dataMap.getDataMap().putLong("Time",System.currentTimeMillis());

        PutDataRequest putDataRequest = dataMap.asPutDataRequest();
        putDataRequest = putDataRequest.setUrgent();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
            @Override
            public void onResult(DataApi.DataItemResult dataItemResult) {
                Log.d(TAG, "Sending new sensor ++++++++" + path +" " + sensorID + ": " + dataItemResult.getStatus().isSuccess());
            }
        });
    }
}
 
開發者ID:swandroid,項目名稱:swan-sense-studio,代碼行數:19,代碼來源:RemoteSensorManager.java

示例14: markAllRead

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void markAllRead() {
    PutDataMapRequest dataMap = PutDataMapRequest.create(Constants.PATH_MARK_READ);

    PutDataRequest request = dataMap.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
            .putDataItem(mGoogleApiClient, request);
    pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
        @Override
        public void onResult(DataApi.DataItemResult dataItemResult) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText(MainActivity.this, "Done", Toast.LENGTH_SHORT);
                }
            });
        }

    });
}
 
開發者ID:glanceable,項目名稱:GlanceTweet,代碼行數:20,代碼來源:MainActivity.java

示例15: filterBySensorIdInBackground

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void filterBySensorIdInBackground(final int sensorId) {
    Log.d(TAG, "filterBySensorId(" + sensorId + ")");

    if (validateConnection()) {
        PutDataMapRequest dataMap = PutDataMapRequest.create("/filter");

        dataMap.getDataMap().putInt(DataMapKeys.FILTER, sensorId);
        dataMap.getDataMap().putLong(DataMapKeys.TIMESTAMP, System.currentTimeMillis());

        PutDataRequest putDataRequest = dataMap.asPutDataRequest();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
            @Override
            public void onResult(DataApi.DataItemResult dataItemResult) {
                Log.d(TAG, "Filter by sensor " + sensorId + ": " + dataItemResult.getStatus().isSuccess());
            }
        });
    }
}
 
開發者ID:IBMCloudiLab,項目名稱:Bluemix-IoT-android-wear,代碼行數:19,代碼來源:RemoteSensorManager.java


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