本文整理汇总了Java中com.google.android.gms.wearable.DataMap.getString方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.getString方法的具体用法?Java DataMap.getString怎么用?Java DataMap.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_BACKGROUND_COLOR)) {
int color = config.getInt(configKey);
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + color);
if (updateUiForKey(configKey, color)) {
uiUpdated = true;
}
}
else if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_SECOND_TIMEZONE)) {
String timezoneID = config.getString(configKey);
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + timezoneID);
if (updateUiForKey(configKey, timezoneID)) {
uiUpdated = true;
}
}
}
adapter.notifyDataSetChanged();
}
示例2: syncSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void syncSensorData(DataMap dataMap, Context context) {//KS
Log.d(TAG, "syncSensorData");
if (dataMap != null) {
String uuid = dataMap.getString("uuid");
Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid);
long started_at = dataMap.getLong("started_at");
Integer latest_battery_level = dataMap.getInt("latest_battery_level");
String sensor_location = dataMap.getString("sensor_location");
Sensor.InitDb(context);//ensure database has already been initialized
if (uuid != null && !uuid.isEmpty()) {
Log.d(TAG, "syncSensorData add Sensor for uuid=" + uuid + " timestamp=" + started_at + " timeString=" + JoH.dateTimeText(started_at));
Sensor sensor = Sensor.getByUuid(uuid);
if (sensor == null) {
Log.d(TAG, "syncSensorData createUpdate new Sensor...");
Sensor.createUpdate(started_at, 0, latest_battery_level, sensor_location, uuid);
Sensor newsensor = Sensor.currentSensor();
if (newsensor != null) {
Log.d(TAG, "syncSensorData createUpdate Sensor with uuid=" + uuid + " started at=" + started_at);
} else
Log.d(TAG, "syncSensorData Failed to createUpdate new Sensor for uuid=" + uuid);
} else
Log.d(TAG, "syncSensorData Sensor already exists with uuid=" + uuid);
}
}
}
示例3: UartConfiguration
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public UartConfiguration(final DataMap dataMap, final long id) {
name = dataMap.getString(Constants.UART.Configuration.NAME);
final ArrayList<DataMap> maps = dataMap.getDataMapArrayList(Constants.UART.Configuration.COMMANDS);
commands = new Command[maps.size()];
for (int i = 0; i < maps.size(); ++i) {
commands[i] = new Command(maps.get(i));
}
this.id = id;
}
示例4: convertDataMapToFeedbackData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Converts the feedback data from a {@link com.google.android.gms.wearable.DataMap} to a
* {@link SessionFeedbackModel.SessionFeedbackData};
*
* The {@code data} is a JSON string. The format of a typical response is:
* <pre>[{"s":"sessionId-1234"},{"q":1,"a":2},{"q":0,"a":1},{"q":3,"a":1},{"q":2,"a":1}]</pre>
*
* @return SessionFeedbackData object, or null if JSON Parsing error
*/
public static SessionFeedbackData convertDataMapToFeedbackData(DataMap data) {
try {
if (data == null){
LOGE(TAG, "Failed to parse session data, DataMap is null");
return null;
}
String jsonString = data.getString("response");
if (TextUtils.isEmpty(jsonString)) {
LOGE(TAG, "Failed to parse session data, empty json string");
return null;
}
LOGD(TAG, "jsonString is: " + jsonString);
JSONArray jsonArray = new JSONArray(jsonString);
if (jsonArray.length() > 0) {
JSONObject sessionObj = (JSONObject) jsonArray.get(0);
String sessionId = sessionObj.getString("s");
int[] answers = new int[4];
for (int i = 0; i < answers.length; i++) {
answers[i] = -1;
}
for (int i = 1; i < jsonArray.length(); i++) {
JSONObject answerObj = (JSONObject) jsonArray.get(i);
int question = answerObj.getInt("q");
int answer = answerObj.getInt("a") + 1;
answers[question] = answer;
}
return new SessionFeedbackData(sessionId, answers[0], answers[1], answers[2],
answers[3], null);
}
} catch (JSONException e) {
LOGE(TAG, "Failed to parse the json received from the wear", e);
}
return null;
}
示例5: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
for (DataEvent dataEvent:dataEventBuffer){
if (dataEvent.getType()==DataEvent.TYPE_CHANGED){
DataMap dataMap= DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
String path=dataEvent.getDataItem().getUri().getPath();
if (path.equals(NOTIFICATION_PATH)){
if (dataMap.containsKey(HIGH_TEMP_KEY)){
mHighTemp = dataMap.getString(HIGH_TEMP_KEY);
}else{
mHighTemp=NOT_FOUND_HIGH_TEMP;
}
if (dataMap.containsKey(LOW_TEMP_KEY)){
mLowTemp = dataMap.getString(LOW_TEMP_KEY);
}else{
mLowTemp=NOT_FOUND_LOW_TEMP;
}
if (dataMap.containsKey(WEATHER_ID_KEY)){
mWeatherId = dataMap.getInt(WEATHER_ID_KEY);
}else{
mWeatherId=NOT_FOUND_WEATHER_ID;
}
saveReceivedValues();
}
}
}
}
示例6: updateUiForConfigDataMap
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void updateUiForConfigDataMap(final DataMap config) {
boolean uiUpdated = false;
for (String configKey : config.keySet()) {
if (!config.containsKey(configKey)) {
continue;
}
if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_BACKGROUND_COLOR)) {
int color = config.getInt(configKey);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + color);
}
if (updateUiForKey(configKey, color)) {
uiUpdated = true;
}
}else if(configKey.equalsIgnoreCase(WatchFaceUtil.KEY_SECOND_TIMEZONE)) {
String timeZoneId = config.getString(configKey);
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Found watch face config key: " + configKey + " -> " + timeZoneId);
}
if (updateUiForKey(configKey, timeZoneId)) {
uiUpdated = true;
}
}
}
if (uiUpdated) {
invalidate();
}
}
示例7: syncStepSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncStepSensorData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncStepSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG, "syncStepSensorData add to Table" );
if (entries != null) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
StepCounter pm = StepCounter.last();
Log.d(TAG, "syncStepSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncStepSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG, "syncStepSensorData add Table record=" + record);
StepCounter data = gson.fromJson(record, StepCounter.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG, "syncStepSensorData add Entry Wear=" + data.toString());
Log.d(TAG, "syncStepSensorData WATCH data.metric=" + data.metric + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"STEP", -1);
}
}
示例8: setWatchStatus
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static void setWatchStatus(DataMap dataMap) {
lastStateWatch = dataMap.getString("lastState", "");
last_transmitter_DataWatch = new TransmitterData();
last_transmitter_DataWatch.timestamp = dataMap.getLong("timestamp", 0);
mStaticStateWatch = dataMap.getInt("mStaticState", 0);
last_battery_level_watch = dataMap.getInt("last_battery_level", -1);
retry_time_watch = dataMap.getLong("retry_time", 0);
failover_time_watch = dataMap.getLong("failover_time", 0);
static_last_hexdump_watch = dataMap.getString("static_last_hexdump", "");
static_last_sent_hexdump_watch = dataMap.getString("static_last_sent_hexdump", "");
}
示例9: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
Log.d(TAG, "onDataChanged called!");
for (DataEvent event : dataEventBuffer) {
DataItem item = event.getDataItem();
if (FORECAST_PATH.equals(item.getUri().getPath())) {
DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap();
mHighTemp = dataMap.getString(MAX_TEMP_KEY);
mLowTemp = dataMap.getString(MIN_TEMP_KEY);
new LoadBitmapAsyncTask().execute(dataMap.getAsset(WEATHER_ICON_KEY));
Log.d(TAG, "Max Temp=" + mHighTemp + "; Min Temp=" + mLowTemp);
}
}
}
示例10: syncHeartSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncHeartSensorData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncHeartSensorData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
Log.d(TAG, "syncHeartSensorData add to Table" );
if (entries != null) {
final Gson gson = JoH.defaultGsonInstance();
//final HeartRate pm = HeartRate.last();
Log.d(TAG, "syncHeartSensorData add Table entries count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncHeartSensorData add Table entry=" + entry);
String record = entry.getString("entry");
if (record != null) {
Log.d(TAG, "syncHeartSensorData add Table record=" + record);
final HeartRate data = gson.fromJson(record, HeartRate.class);
if (data != null) {
timeOfLastEntry = (long) data.timestamp + 1;
Log.d(TAG, "syncHeartSensorData add Entry Wear=" + data.toString() + " "+record);
Log.d(TAG, "syncHeartSensorData WATCH data.metric=" + data.bpm + " timestamp=" + JoH.dateTimeText((long) data.timestamp));
if (!bBenchmark)
data.saveit();
}
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"HEART", -1);
}
}
示例11: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
for (DataEvent dataEvent : dataEventBuffer) {
if (dataEvent.getType() == DataEvent.TYPE_CHANGED){
DataItem dataItem = dataEvent.getDataItem();
if (dataItem.getUri().getPath().equals(KEY_PATH)) {
DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
if (dataMap.containsKey(KEY_WEATHER_ID)) {
int weatherId = dataMap.getInt(KEY_WEATHER_ID);
Drawable b = getResources().getDrawable(getArtResourceForWeatherCondition(weatherId));
Bitmap icon = ((BitmapDrawable) b).getBitmap();
float scaledWidth = (mMaxTempPaint.getTextSize() / icon.getHeight()) * icon.getWidth();
mWeatherArt = Bitmap.createScaledBitmap(icon, (int) scaledWidth, (int) mMaxTempPaint.getTextSize(), true);
}
if (dataMap.containsKey(KEY_MAX_TEMP)) {
mMaxTemp = dataMap.getString(KEY_MAX_TEMP);
}
if (dataMap.containsKey(KEY_MIN_TEMP)) {
mMinTemp = dataMap.getString(KEY_MIN_TEMP);
}
Log.d(LOG_TAG, "weatherId" +dataMap.getInt(KEY_WEATHER_ID));
Log.d(LOG_TAG, "mMaxTemp" +dataMap.getString(KEY_MAX_TEMP));
Log.d(LOG_TAG, "mMinTemp" +dataMap.getString(KEY_MIN_TEMP));
invalidate();
}
}
}
}
示例12: onReceive
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final PowerManager.WakeLock wl = JoH.getWakeLock("circle-message-receiver", 60000);
try {
DataMap dataMap;
Bundle bundle = intent.getBundleExtra("msg");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
String msg = dataMap.getString("msg", "");
int length = dataMap.getInt("length", 0);
JoH.static_toast(xdrip.getAppContext(), msg, length);
}
bundle = intent.getBundleExtra("steps");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
if (mTimeStepsRcvd <= dataMap.getLong("steps_timestamp", 0)) {
mStepsCount = dataMap.getInt("steps", 0);
mTimeStepsRcvd = dataMap.getLong("steps_timestamp", 0);
}
}
bundle = intent.getBundleExtra("data");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
setSgvLevel((int) dataMap.getLong("sgvLevel"));
Log.d(TAG, "CircleWatchface sgv level : " + getSgvLevel());
setSgvString(dataMap.getString("sgvString"));
Log.d(TAG, "CircleWatchface sgv string : " + getSgvString());
setRawString(dataMap.getString("rawString"));
setDelta(dataMap.getString("delta"));
setDatetime(dataMap.getDouble("timestamp"));
mExtraStatusLine = dataMap.getString("extra_status_line");
addToWatchSet(dataMap);
//start animation?
// dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (getSgvString().equals("100") || getSgvString().equals("5.5") || getSgvString().equals("5,5"))) {
startAnimation();
}
prepareLayout();
prepareDrawTime();
invalidate();
}
//status
bundle = intent.getBundleExtra("status");
if (bundle != null) {
dataMap = DataMap.fromBundle(bundle);
setStatusString(dataMap.getString("externalStatusString"));
prepareLayout();
prepareDrawTime();
invalidate();
}
} finally {
JoH.releaseWakeLock(wl);
}
}
示例13: syncTreatmentsData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncTreatmentsData(DataMap dataMap, boolean bBenchmark) {
Log.d(TAG, "syncTreatmentsData");
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
long timeOfLastEntry = 0;
if (entries != null) {
Log.d(TAG, "syncTreatmentsData count=" + entries.size());
for (DataMap entry : entries) {
if (entry != null) {
Log.d(TAG, "syncTreatmentsData entry=" + entry);
String record = entry.getString("entry");
if (record != null && record.length() > 1) {
Log.d(TAG, "Received wearable: voice payload: " + record);
long timestamp = entry.getLong("timestamp");
if (timestamp <= PersistentStore.getLong(LAST_RECORD_TIMESTAMP)) {
Log.e(TAG,"Ignoring repeated or older sync timestamp");
continue;
}
final long since = JoH.msSince(timestamp);
if ((since < 0) || (since > Constants.HOUR_IN_MS * 72)) {
JoH.static_toast_long("Rejecting wear treatment as time out of range!");
UserError.Log.e(TAG, "Rejecting wear treatment due to time: " + record + " since: " + since);
} else {
if (record.contains("uuid null")) {
Log.e(TAG,"Skipping xx uuid null record!");
continue;
}
receivedText(getApplicationContext(), record);
PersistentStore.setLong(LAST_RECORD_TIMESTAMP, timestamp);
}
Log.d(TAG, "syncTreatmentsData add Table record=" + record);
timeOfLastEntry = (long) timestamp + 1;
Log.d(TAG, "syncTreatmentsData WATCH treatments timestamp=" + JoH.dateTimeText(timestamp));
}
}
}
sendDataReceived(DATA_ITEM_RECEIVED_PATH,"DATA_RECEIVED_LOGS count=" + entries.size(), timeOfLastEntry, bBenchmark?"BM":"TREATMENTS", -1);
}
}
示例14: Command
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
Command(final DataMap dataMap) {
icon = Icon.values()[dataMap.getInt(Constants.UART.Configuration.Command.ICON_ID)];
command = dataMap.getString(Constants.UART.Configuration.Command.MESSAGE);
eol = Eol.values()[dataMap.getInt(Constants.UART.Configuration.Command.EOL)];
}
示例15: syncBloodTestData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private synchronized void syncBloodTestData(DataMap dataMap, Context context) {//KS
Log.d(TAG, "syncBloodTestData");
boolean changed = false;
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
Gson gson = new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Date.class, new DateTypeAdapter())
.serializeSpecialFloatingPointValues()
.create();
Log.d(TAG, "syncBloodTestData add BloodTest Table entries count=" + entries.size());
Sensor.InitDb(context);//ensure database has already been initialized
for (DataMap entry : entries) {
if (entry != null) {
String record = entry.getString("data");
if (record != null) {
BloodTest data = gson.fromJson(record, BloodTest.class);
BloodTest exists = BloodTest.byUUID(data.uuid);
if (exists != null) {
Log.d(TAG, "syncBloodTestData save existing BloodTest for uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " mgdl=" + data.mgdl + " state=" + data.state);
if (exists.mgdl != data.mgdl || exists.state != data.state || exists.timestamp != data.timestamp) {//state indicates if deleted
changed = true;
}
exists.mgdl = data.mgdl;
exists.created_timestamp = data.created_timestamp;
exists.source = data.source;
exists.state = data.state;
exists.timestamp = data.timestamp;
exists.save();
}
else {
changed = true;
data.save();
Log.d(TAG, "syncBloodTestData create new BloodTest for uuid=" + data.uuid + " timestamp=" + data.timestamp + " timeString=" + JoH.dateTimeText(data.timestamp) + " mgdl=" + data.mgdl + " state=" + data.state);
}
}
}
}
if (changed) {
showTreatments(context, "bts");
}
}
}