当前位置: 首页>>代码示例>>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;未经允许,请勿转载。