本文整理汇总了Java中com.google.android.gms.wearable.DataMap.putString方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.putString方法的具体用法?Java DataMap.putString怎么用?Java DataMap.putString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.putString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: generateDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private DataMap generateDataMap(CustomRules aRule)
{
DataMap dataMap=new DataMap();
dataMap.putLong(Const.KEY_CURRENTTIMESTAMP,System.currentTimeMillis());
dataMap.putLong(Const.KEY_RULE_ID,aRule.getId());
dataMap.putString(Const.KEY_RULE_CATEGORY,aRule.getCategory());
dataMap.putString(Const.KEY_RULE_CONSTRAINT1,aRule.getConstraint_1());
dataMap.putString(Const.KEY_RULE_CONSTRAINT2,aRule.getConstraint_2());
dataMap.putString(Const.KEY_RULE_CONSTRAINT3,aRule.getConstraint_3());
//if null, we send the number -100000. We will have to check on the other side
dataMap.putDouble(Const.KEY_RULE_VAL1_MIN, formatValue(aRule.getVal_1_min()));
dataMap.putDouble(Const.KEY_RULE_VAL1_MAX,formatValue(aRule.getVal_1_max()));
dataMap.putDouble(Const.KEY_RULE_VAL2_MIN,formatValue(aRule.getVal_2_min()));
dataMap.putDouble(Const.KEY_RULE_VAL2_MAX, formatValue(aRule.getVal_2_max()));
return dataMap;
}
示例3: prepareDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Used when a user update a rule. It will be send to the watch
* @param rule : The current rule we want to send though a datamap (container)
* @return The datamap that contain the rule
*/
private DataMap prepareDataMap(CustomRules rule)
{
//create the value container
DataMap dataContainer=new DataMap();
//insert the rule value
dataContainer.putLong(Const.KEY_RULE_ID,rule.getId());
dataContainer.putString(Const.KEY_RULE_CATEGORY,rule.getCategory());
dataContainer.putString(Const.KEY_RULE_CONSTRAINT1,rule.getConstraint_1());
dataContainer.putString(Const.KEY_RULE_CONSTRAINT2,rule.getConstraint_2());
dataContainer.putString(Const.KEY_RULE_CONSTRAINT3,rule.getConstraint_3());
dataContainer.putDouble(Const.KEY_RULE_VAL1_MIN,formatDataMapValue( rule.getVal_1_min()));
dataContainer.putDouble(Const.KEY_RULE_VAL1_MAX,formatDataMapValue(rule.getVal_1_max()));
dataContainer.putDouble(Const.KEY_RULE_VAL2_MIN,formatDataMapValue(rule.getVal_2_min()));
dataContainer.putDouble(Const.KEY_RULE_VAL2_MAX,formatDataMapValue(rule.getVal_2_max()));
dataContainer.putLong(Const.KEY_CURRENTTIMESTAMP,System.currentTimeMillis());
return dataContainer;
}
示例4: Approve
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public void Approve(View myview) {
if (watchkeypad) {
//Treatments.create(carbs, insulin, thisnotes, new Date().getTime());
DataMap dataMap = new DataMap();
dataMap.putDouble("timeoffset", timeoffset);
dataMap.putDouble("carbs", carbs);
dataMap.putDouble("insulin", insulin);
dataMap.putDouble("bloodtest", bloodtest);
dataMap.putString("notes", thisnotes);
//dataMap.putLong("timestamp", System.currentTimeMillis());
ListenerService.createTreatment(dataMap, this);
}
else
SendData(this, WEARABLE_APPROVE_TREATMENT, null);
finish();
}
示例5: resendData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void resendData() {
Log.d(TAG, "resendData ENTER");
forceGoogleApiConnect();
Log.d(TAG, "resendData googleApiClient connected ENTER");
long startTime = new Date().getTime() - (60000 * 60 * 24);
BgReading last_bg = BgReading.last();
if (last_bg != null) {
List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(getApplicationContext());
if (!graph_bgs.isEmpty()) {
final int battery = PowerStateReceiver.getBatteryLevel(getApplicationContext());
DataMap entries = dataMap(last_bg, mPrefs, bgGraphBuilder, battery);
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
for (BgReading bg : graph_bgs) {
dataMaps.add(dataMap(bg, mPrefs, bgGraphBuilder, battery));
}
entries.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
entries.putDataMapArrayList("entries", dataMaps);
if (mPrefs.getBoolean("extra_status_line", false)) {
entries.putString("extra_status_line", Home.extraStatusLine());
}
new SendToDataLayerThread(WEARABLE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, entries);
}
}
}
示例6: sendActiveBtDeviceData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendActiveBtDeviceData() {//KS
if (is_using_bt) {//only required for Collector running on watch
forceGoogleApiConnect();
ActiveBluetoothDevice btDevice = ActiveBluetoothDevice.first();
if (btDevice != null) {
if (wear_integration) {
DataMap dataMap = new DataMap();
Log.d(TAG, "sendActiveBtDeviceData name=" + btDevice.name + " address=" + btDevice.address + " connected=" + btDevice.connected);
dataMap.putLong("time", new Date().getTime()); // MOST IMPORTANT LINE FOR TIMESTAMP
dataMap.putString("name", btDevice.name);
dataMap.putString("address", btDevice.address);
dataMap.putBoolean("connected", btDevice.connected);
new SendToDataLayerThread(WEARABLE_ACTIVEBTDEVICE_DATA_PATH, googleApiClient).executeOnExecutor(xdrip.executor, dataMap);
}
}
} else {
Log.d(TAG, "Not sending activebluetoothdevice data as we are not using bt");
}
}
示例7: onRequestSuccess
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onRequestSuccess(List<Object> result, Class<?> clazz) {
if (clazz == Trigger.class) {
ArrayList<Trigger> triggersList = new ArrayList<>();
for (Object object : result) {
if (object instanceof Trigger) {
triggersList.add((Trigger) object);
}
}
Collections.sort(triggersList, new TriggerComparator());
if (googleApiClient.isConnected()) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ZabbkitConstants.PATH_DATA_RESULT);
dataMapRequest.getDataMap().putDouble(ZabbkitConstants.TIMESTAMP, System.currentTimeMillis());
ArrayList<DataMap> dataMapArray = new ArrayList<>();
for (Trigger trigger : triggersList) {
DataMap dataMap = new DataMap();
dataMap.putString(ZabbkitConstants.REQUEST_RESULT_DESCRIPTION, trigger.getDescription());
dataMap.putString(ZabbkitConstants.REQUEST_RESULT_PRIORITY, trigger.getPriority());
dataMapArray.add(dataMap);
}
dataMapRequest.getDataMap().putDataMapArrayList(ZabbkitConstants.REQUEST_RESULT_ARRAY, dataMapArray);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
} else {
Log.e("Error!", "No connection to wearable available!");
}
}
}
示例8: 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);
}
示例9: sendConfigUpdateMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void sendConfigUpdateMessage(String configKey, String value) {
if (mPeerId != null) {
DataMap config = new DataMap();
//config.putLong(WatchFaceUtil.KEY_TIMESTAMP, new Date().getTime());
config.putString(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 + " -> "
+ value);
}
}
}
示例10: 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();
}
}
示例11: sendReplyMsg
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void sendReplyMsg (String msg, long last_timestamp, String path, boolean showToast, int length) {
Log.d(TAG, "sendReplyMsg msg=" + msg);
DataMap dataMap = new DataMap();
dataMap.putString("msg", msg);
dataMap.putLong("last_timestamp", last_timestamp);
dataMap.putString("action_path", path);//eg. START_COLLECTOR_PATH
Log.d(TAG, "sendReplyMsg dataMap=" + dataMap);
if (showToast) {
sendLocalToast(msg, length);
}
sendData(WEARABLE_REPLYMSG_PATH, dataMap.toByteArray());
}
示例12: resendData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static void resendData(Context context, int battery) {//KS
Log.d("BgSendQueue", "resendData enter battery=" + battery);
long startTime = new Date().getTime() - (60000 * 60 * 24);
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra("message", "ACTION_G5BG");
BgReading last_bg = BgReading.last();
if (last_bg != null) {
Log.d("BgSendQueue", "resendData last_bg.timestamp:" + JoH.dateTimeText(last_bg.timestamp));
}
List<BgReading> graph_bgs = BgReading.latestForGraph(60, startTime);
BgGraphBuilder bgGraphBuilder = new BgGraphBuilder(context.getApplicationContext());
if (!graph_bgs.isEmpty()) {
Log.d("BgSendQueue", "resendData graph_bgs size=" + graph_bgs.size());
final ArrayList<DataMap> dataMaps = new ArrayList<>(graph_bgs.size());
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
DataMap entries = dataMap(last_bg, sharedPrefs, bgGraphBuilder, context, battery);
for (BgReading bg : graph_bgs) {
dataMaps.add(dataMap(bg, sharedPrefs, bgGraphBuilder, context, battery));
}
entries.putDataMapArrayList("entries", dataMaps);
if (sharedPrefs.getBoolean("extra_status_line", false)) {
//messageIntent.putExtra("extra_status_line", extraStatusLine(sharedPrefs));
entries.putString("extra_status_line", extraStatusLine(sharedPrefs));
}
Log.d("BgSendQueue", "resendData entries=" + entries);
messageIntent.putExtra("data", entries.toBundle());
DataMap stepsDataMap = getSensorSteps(sharedPrefs);
if (stepsDataMap != null) {
messageIntent.putExtra("steps", stepsDataMap.toBundle());
}
LocalBroadcastManager.getInstance(context).sendBroadcast(messageIntent);
}
}
示例13: sendPersistentStore
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void sendPersistentStore() {
if (DexCollectionType.getDexCollectionType().equals(DexCollectionType.DexcomG5)) {
DataMap dataMap = new DataMap();
String dex_txid = mPrefs.getString("dex_txid", "ABCDEF");
dataMap.putByteArray(G5_BATTERY_MARKER, PersistentStore.getBytes(G5_BATTERY_MARKER + dex_txid));
dataMap.putLong(G5_BATTERY_FROM_MARKER, PersistentStore.getLong(G5_BATTERY_FROM_MARKER + dex_txid));
dataMap.putString("dex_txid", dex_txid);
dataMap.putByteArray(G5_FIRMWARE_MARKER, PersistentStore.getBytes(G5_FIRMWARE_MARKER + dex_txid));
dataMap.putString("dex_txid", dex_txid);
sendData(WEARABLE_G5BATTERY_PAYLOAD, dataMap.toByteArray());
}
}
示例14: 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;
}
示例15: addStringKeyIfMissing
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void addStringKeyIfMissing(DataMap config, String key, String value) {
if (!config.containsKey(key)) {
config.putString(key, value);
}
}