本文整理汇总了Java中com.google.android.gms.wearable.DataMap.putInt方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.putInt方法的具体用法?Java DataMap.putInt怎么用?Java DataMap.putInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.putInt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConfigurationAddedOrEdited
import com.google.android.gms.wearable.DataMap; //导入方法依赖的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);
}
示例2: sendData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendData() {
ArrayList<Double> tempValues = ForecastFragment.getTempValues();
Log.v("TAG", tempValues.size()+"");
final DataMap dataMap = new DataMap();
dataMap.putDouble("max", tempValues.get(0));
dataMap.putDouble("min", tempValues.get(1));
dataMap.putInt("icon", ForecastFragment.getIconId());
dataMap.putLong("timestamp", System.currentTimeMillis());
new Thread( new Runnable() {
@Override
public void run() {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(MOBILE_MESSAGE_PATH).setUrgent();
dataMapRequest.getDataMap().putAll(dataMap);
PutDataRequest request = dataMapRequest.asPutDataRequest();
DataApi.DataItemResult result = Wearable.DataApi.putDataItem(mApiClient, request).await();
if(result.getStatus().isSuccess()){
Log.v("TAG", "Sent successfully");
}else {
Log.v("TAG", "Failed to send");
}
}
}).start();
}
示例3: sendActionTypeMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的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;
}
示例4: sendInteractionTypeMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的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;
}
示例5: sendDataToWear
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendDataToWear() {
Log.d(TAG, "sendDataToWear: ");
String locationQuery = Utility.getPreferredLocation(this);
Uri weatherUri = WeatherContract.WeatherEntry.buildWeatherLocationWithDate(locationQuery, System.currentTimeMillis());
Cursor cursor = getBaseContext().getContentResolver().query(weatherUri, NOTIFY_WEATHER_PROJECTION, null, null, null);
DataMap dataMap = new DataMap();
if (cursor.moveToFirst()) {
int weatherId = cursor.getInt(INDEX_WEATHER_ID);
double high = cursor.getDouble(INDEX_MAX_TEMP);
double low = cursor.getDouble(INDEX_MIN_TEMP);
high = Utility.getFormattedTemperature(this, high);
low = Utility.getFormattedTemperature(this, low);
Log.d(TAG, "sendDataToWear: high temp: " + high);
Log.d(TAG, "sendDataToWear: low temp: " + low);
BigDecimal highBD = new BigDecimal(high);
highBD = highBD.setScale(2, BigDecimal.ROUND_UP);
BigDecimal lowBD = new BigDecimal(low);
lowBD = lowBD.setScale(2, BigDecimal.ROUND_UP);
dataMap.putLong("time", new Date().getTime());
dataMap.putInt(Constants.KEY_WEATHER_TEMP_MAX, highBD.intValue());
dataMap.putInt(Constants.KEY_WEATHER_TEMP_MIN, lowBD.intValue());
dataMap.putInt(Constants.KEY_WEATHER_ID, weatherId);
dataMap.putString(Constants.KEY_WEATHER_UNIT, Utility.isMetric(this) ? "C" : "F");
}
DataManager.getInstance().syncDataMap(mGoogleApiClient, dataMap, Constants.PATH_WEATHER_DATA, this);
}
示例6: updateConfigDataItem
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateConfigDataItem(final int colorID) {
DataMap configKeysToOverwrite = new DataMap();
//configKeysToOverwrite.putLong(WatchFaceUtil.KEY_TIMESTAMP, new Date().getTime());
configKeysToOverwrite.putInt(WatchFaceUtil.KEY_BACKGROUND_COLOR,
colorID);
WatchFaceUtil.overwriteKeysInConfigDataMap(mGoogleApiClient, configKeysToOverwrite);
}
示例7: sendConfigUpdateMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendConfigUpdateMessage(String configKey, int value) {
if (mPeerId != null) {
DataMap config = new DataMap();
//config.putLong(WatchFaceUtil.KEY_TIMESTAMP, new Date().getTime());
config.putInt(configKey, value);
byte[] rawData = config.toByteArray();
Wearable.MessageApi.sendMessage(mGoogleApiClient, mPeerId, WatchFaceUtil.PATH_WITH_FEATURE, rawData);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Sent watch face config message: " + configKey + " -> "
+ Integer.toHexString(value));
}
}
}
示例8: sendPrefSettings
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendPrefSettings() {//KS
Log.d(TAG, "sendPrefSettings enter");
forceGoogleApiConnect();
DataMap dataMap = new DataMap();
boolean enable_wearG5 = mPrefs.getBoolean("enable_wearG5", false);
boolean force_wearG5 = mPrefs.getBoolean("force_wearG5", false);
String node_wearG5 = mPrefs.getString("node_wearG5", "");
String dex_txid = mPrefs.getString("dex_txid", "ABCDEF");
boolean show_wear_treatments = mPrefs.getBoolean("show_wear_treatments", false);
if (localnode == null || (localnode != null && localnode.isEmpty())) setLocalNodeName();
Log.d(TAG, "sendPrefSettings enable_wearG5: " + enable_wearG5 + " force_wearG5:" + force_wearG5 + " node_wearG5:" + node_wearG5 + " localnode:" + localnode + " dex_txid:" + dex_txid + " show_wear_treatments:" + show_wear_treatments);
dataMap.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
dataMap.putBoolean("enable_wearG5", enable_wearG5);
dataMap.putBoolean("force_wearG5", force_wearG5);
if (force_wearG5) {
dataMap.putString("node_wearG5", localnode);
} else {
if (node_wearG5.equals(localnode)) {
dataMap.putString("node_wearG5", "");
} else {
dataMap.putString("node_wearG5", node_wearG5);
}
}
dataMap.putString("dex_txid", dex_txid);
dataMap.putInt("bridge_battery", mPrefs.getInt("bridge_battery", -1));//Used in DexCollectionService
dataMap.putInt("nfc_sensor_age", mPrefs.getInt("nfc_sensor_age", -1));//Used in DexCollectionService for LimiTTer
dataMap.putBoolean("bg_notifications_watch", mPrefs.getBoolean("bg_notifications", false));
dataMap.putBoolean("persistent_high_alert_enabled_watch", mPrefs.getBoolean("persistent_high_alert_enabled", false));
dataMap.putBoolean("show_wear_treatments", show_wear_treatments);
sendData(WEARABLE_PREF_DATA_PATH, dataMap.toByteArray());
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
if (!node_wearG5.equals(dataMap.getString("node_wearG5", ""))) {
Log.d(TAG, "sendPrefSettings save to SharedPreferences - node_wearG5:" + dataMap.getString("node_wearG5", ""));
prefs.putString("node_wearG5", dataMap.getString("node_wearG5", ""));
prefs.commit();
}
}
示例9: getWatchStatus
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getWatchStatus() {
DataMap dataMap = new DataMap();
dataMap.putString("lastState", lastState);
if (last_transmitter_Data != null) dataMap.putLong("timestamp", last_transmitter_Data.timestamp);
dataMap.putInt("mStaticState", mStaticState);
dataMap.putInt("last_battery_level", last_battery_level);
dataMap.putLong("retry_time", retry_time);
dataMap.putLong("failover_time", failover_time);
dataMap.putString("static_last_hexdump", static_last_hexdump);
dataMap.putString("static_last_sent_hexdump", static_last_sent_hexdump);
return dataMap;
}
示例10: getSensorSteps
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static DataMap getSensorSteps(SharedPreferences prefs) {
Log.d("BgSendQueue", "getSensorSteps");
DataMap dataMap = new DataMap();
final long t = System.currentTimeMillis();
final PebbleMovement pm = PebbleMovement.last();
final boolean show_steps = prefs.getBoolean("showSteps", true);
final boolean show_heart_rate = prefs.getBoolean("showHeartRate", true);
final boolean use_wear_health = prefs.getBoolean("use_wear_health", true);
if (use_wear_health || show_steps) {
boolean sameDay = pm != null ? ListenerService.isSameDay(t, pm.timestamp) : false;
if (!sameDay) {
dataMap.putInt("steps", 0);
dataMap.putLong("steps_timestamp", t);
Log.d("BgSendQueue", "getSensorSteps isSameDay false t=" + JoH.dateTimeText(t));
}
else {
dataMap.putInt("steps", pm.metric);
dataMap.putLong("steps_timestamp", pm.timestamp);
Log.d("BgSendQueue", "getSensorSteps isSameDay true pm.timestamp=" + JoH.dateTimeText(pm.timestamp) + " metric=" + pm.metric);
}
}
if (use_wear_health && show_heart_rate) {
final HeartRate lastHeartRateReading = HeartRate.last();
if (lastHeartRateReading != null) {
dataMap.putInt("heart_rate", lastHeartRateReading.bpm);
dataMap.putLong("heart_rate_timestamp", lastHeartRateReading.timestamp);
}
}
return dataMap;
}
示例11: addIntKeyIfMissing
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void addIntKeyIfMissing(DataMap config, String key, int color) {
if (!config.containsKey(key)) {
config.putInt(key, color);
}
}
示例12: sendSensorLocalMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendSensorLocalMessage(int steps, long timestamp) {
DataMap dataMap = new DataMap();
dataMap.putInt("steps", steps);
dataMap.putLong("steps_timestamp", timestamp);
sendLocalMessage("steps", dataMap);
}
示例13: sendLocalToast
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendLocalToast(String msg, int length) {
DataMap dataMap = new DataMap();
dataMap.putString("msg", msg);
dataMap.putInt("length", length);
sendLocalMessage("msg", dataMap);
}
示例14: dataMapSingleBG
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
String units = MainApp.getConfigBuilder().getProfileUnits();
Double lowLine = SafeParse.stringToDouble(mPrefs.getString("low_mark", "0"));
Double highLine = SafeParse.stringToDouble(mPrefs.getString("high_mark", "0"));
//convert to mg/dl
if (!units.equals(Constants.MGDL)) {
lowLine *= Constants.MMOLL_TO_MGDL;
highLine *= Constants.MMOLL_TO_MGDL;
}
if (lowLine < 1) {
lowLine = OverviewPlugin.bgTargetLow;
}
if (highLine < 1) {
highLine = OverviewPlugin.bgTargetHigh;
}
long sgvLevel = 0l;
if (lastBG.value > highLine) {
sgvLevel = 1;
} else if (lastBG.value < lowLine) {
sgvLevel = -1;
}
DataMap dataMap = new DataMap();
int battery = getBatteryLevel(getApplicationContext());
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
dataMap.putDouble("timestamp", lastBG.date);
if (glucoseStatus == null) {
dataMap.putString("slopeArrow", "");
dataMap.putString("delta", "");
dataMap.putString("avgDelta", "");
} else {
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
}
dataMap.putString("battery", "" + battery);
dataMap.putLong("sgvLevel", sgvLevel);
dataMap.putInt("batteryLevel", (battery >= 30) ? 1 : 0);
dataMap.putDouble("sgvDouble", lastBG.value);
dataMap.putDouble("high", highLine);
dataMap.putDouble("low", lowLine);
return dataMap;
}