當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMap.getBoolean方法代碼示例

本文整理匯總了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);
            }
        }
    }
}
 
開發者ID:kevalpatel2106,項目名稱:android-samples,代碼行數:32,代碼來源:WearService.java

示例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();
                }
            }
        }
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:33,代碼來源:ListenerService.java

示例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();
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:82,代碼來源:WatchUpdaterService.java


注:本文中的com.google.android.gms.wearable.DataMap.getBoolean方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。