本文整理汇总了Java中com.google.android.gms.wearable.DataMap.getBoolean方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.getBoolean方法的具体用法?Java DataMap.getBoolean怎么用?Java DataMap.getBoolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.getBoolean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDataChanged
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
super.onDataChanged(dataEventBuffer);
//This method will call while any changes in data map occurs from watch side
//This is data map. So, message delivery is guaranteed.
for (DataEvent dataEvent : dataEventBuffer) {
//Check for only those data who changed
if (dataEvent.getType() == DataEvent.TYPE_CHANGED) {
DataMap dataMap = DataMapItem.fromDataItem(dataEvent.getDataItem()).getDataMap();
//Check if the data map path matches with the step tracking status path
String path = dataEvent.getDataItem().getUri().getPath();
if (path.equals(STEP_TRACKING_STATUS_PATH)) {
//Read the values
boolean isTracking = dataMap.getBoolean("status");
long timeStamp = dataMap.getLong("status-time");
//send broadcast to update the UI in MainActivity based on the tracking status
Intent intent = new Intent(TRACKING_STATUS_ACTION);
intent.putExtra("status", isTracking);
intent.putExtra("status-time", timeStamp);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
Log.d("Tracking status: ", isTracking + " Time: " + timeStamp);
}
}
}
}
示例2: syncActiveBtDeviceData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void syncActiveBtDeviceData(DataMap dataMap, Context context) {//KS
Log.d(TAG, "syncActiveBtDeviceData");
if (dataMap != null) {
String name = dataMap.getString("name", "");
String address = dataMap.getString("address", "");
Boolean connected = dataMap.getBoolean("connected", false);
Log.d(TAG, "syncActiveBtDeviceData add ActiveBluetoothDevice for name=" + name + " address=" + address + " connected=" + connected);
Sensor.InitDb(context);//ensure database has already been initialized
if (name != null && !name.isEmpty() && address != null && !address.isEmpty()) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
synchronized (ActiveBluetoothDevice.table_lock) {
ActiveBluetoothDevice btDevice = new Select().from(ActiveBluetoothDevice.class)
.orderBy("_ID desc")
.executeSingle();
prefs.edit().putString("last_connected_device_address", address).apply();
if (btDevice == null) {
ActiveBluetoothDevice newBtDevice = new ActiveBluetoothDevice();
newBtDevice.name = name;
newBtDevice.address = address;
newBtDevice.connected = connected;
newBtDevice.save();
} else {
btDevice.name = name;
btDevice.address = address;
btDevice.connected = connected;
btDevice.save();
}
}
}
}
}
示例3: syncPrefData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void syncPrefData(DataMap dataMap) {
boolean enable_wearG5 = dataMap.getBoolean("enable_wearG5", false);
boolean force_wearG5 = dataMap.getBoolean("force_wearG5", false);
String node_wearG5 = dataMap.getString("node_wearG5", "");
String dex_txid = dataMap.getString("dex_txid", "");
int bridge_battery = dataMap.getInt("bridge_battery", -1);//Used in DexCollectionService
int nfc_sensor_age = dataMap.getInt("nfc_sensor_age", -1);//Used in DexCollectionService LimiTTer
boolean bg_notifications_watch = dataMap.getBoolean("bg_notifications_watch", false);
boolean persistent_high_alert_enabled_watch = dataMap.getBoolean("persistent_high_alert_enabled_watch", false);
boolean show_wear_treatments = dataMap.getBoolean("show_wear_treatments", false);
boolean change = false;
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
Log.d(TAG, "syncPrefData enable_wearG5: " + enable_wearG5 + " force_wearG5: " + force_wearG5 + " node_wearG5:" + node_wearG5 + " dex_txid: " + dex_txid);
if (bridge_battery != mPrefs.getInt("bridge_battery", -1)) {//Used by DexCollectionService
prefs.putInt("bridge_battery", bridge_battery);
prefs.commit();
Log.d(TAG, "syncPrefData commit bridge_battery: " + bridge_battery);
CheckBridgeBattery.checkBridgeBattery();
if (force_wearG5 && CheckBridgeBattery.checkForceWearBridgeBattery()) {
force_wearG5 = false;
change = true;
Log.d(TAG, "syncPrefData disable_wearG5_on_lowbattery=true; switch force_wearG5:" + force_wearG5);
String msg = getResources().getString(R.string.notify_when_wear_low_battery);
JoH.static_toast_long(msg);
sendWearLocalToast(msg, Toast.LENGTH_LONG);
}
}
if (!node_wearG5.equals(mPrefs.getString("node_wearG5", ""))) {
change = true;
prefs.putString("node_wearG5", node_wearG5);
Log.d(TAG, "syncPrefData node_wearG5:" + node_wearG5);
}
if (/*force_wearG5 &&*/ force_wearG5 != mPrefs.getBoolean("force_wearG5", false)) {
change = true;
prefs.putBoolean("force_wearG5", force_wearG5);
Log.d(TAG, "syncPrefData commit force_wearG5:" + force_wearG5);
if (force_wearG5) {
final PendingIntent pendingIntent = android.app.PendingIntent.getActivity(xdrip.getAppContext(), 0, new Intent(xdrip.getAppContext(), Home.class), android.app.PendingIntent.FLAG_UPDATE_CURRENT);
showNotification("Force Wear Enabled", node_wearG5 + " Watch has enabled Force Wear Collection Service", pendingIntent, 771, true, true, true);
}
}
if (nfc_sensor_age != mPrefs.getInt("nfc_sensor_age", 0)) {//Used by DexCollectionService
change = true;
prefs.putInt("nfc_sensor_age", nfc_sensor_age);
Log.d(TAG, "syncPrefData commit nfc_sensor_age: " + nfc_sensor_age);
}
if (bg_notifications_watch != mPrefs.getBoolean("bg_notifications_watch", false)) {
change = true;
prefs.putBoolean("bg_notifications_watch", bg_notifications_watch);
Log.d(TAG, "syncPrefData commit bg_notifications_watch: " + bg_notifications_watch);
}
PersistentStore.setBoolean("bg_notifications_watch", bg_notifications_watch);
PersistentStore.setBoolean("persistent_high_alert_enabled_watch", persistent_high_alert_enabled_watch);
if (/*enable_wearG5 &&*/ enable_wearG5 != mPrefs.getBoolean("enable_wearG5", false)) {
change = true;
prefs.putBoolean("enable_wearG5", enable_wearG5);
Log.d(TAG, "syncPrefData commit enable_wearG5: " + enable_wearG5);
}
if (show_wear_treatments != mPrefs.getBoolean("show_wear_treatments", false)) {
change = true;
prefs.putBoolean("show_wear_treatments", show_wear_treatments);
Log.d(TAG, "syncPrefData show_wear_treatments:" + show_wear_treatments);
}
if (change) {
prefs.commit();
}
else if (!dex_txid.equals(mPrefs.getString("dex_txid", "default"))) {
sendPrefSettings();
processConnect();
}
}