Example usage for android.preference CheckBoxPreference isChecked

List of usage examples for android.preference CheckBoxPreference isChecked

Introduction

In this page you can find the example usage for android.preference CheckBoxPreference isChecked.

Prototype

public boolean isChecked() 

Source Link

Document

Returns the checked state.

Usage

From source file:com.aware.Aware_Preferences.java

/**
 * Telephony module settings UI//from   w  w w  .j a  va 2s.  com
 */
private void telephony() {
    final CheckBoxPreference telephony = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_TELEPHONY);
    telephony.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_TELEPHONY).equals("true"));
    telephony.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_TELEPHONY,
                    telephony.isChecked());
            if (telephony.isChecked()) {
                framework.startTelephony();
            } else {
                framework.stopTelephony();
            }
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Processor module settings UI//from  w w  w.  ja v  a2 s .  com
 */
private void processor() {
    final CheckBoxPreference processor = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_PROCESSOR);
    processor.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_PROCESSOR).equals("true"));
    processor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_PROCESSOR,
                    processor.isChecked());
            if (processor.isChecked()) {
                framework.startProcessor();
            } else {
                framework.stopProcessor();
            }
            return true;
        }
    });

    final EditTextPreference frequencyProcessor = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_PROCESSOR);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR).length() > 0) {
        frequencyProcessor.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR) + " seconds");
    }
    frequencyProcessor
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR));
    frequencyProcessor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROCESSOR, (String) newValue);
            frequencyProcessor.setSummary((String) newValue + " seconds");
            framework.startProcessor();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Applications module settings UI/*from   w  w  w  .j  a v  a 2  s.c om*/
 */
private void applications() {
    final CheckBoxPreference notifications = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_NOTIFICATIONS);
    notifications.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS).equals("true"));
    notifications.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && notifications.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS,
                        notifications.isChecked());
                notifications.setChecked(true);
                framework.startApplications();
                return true;
            }
            if (!isAccessibilityServiceActive()) {
                showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS, false);
            notifications.setChecked(false);
            return false;
        }
    });
    final CheckBoxPreference crashes = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_CRASHES);
    crashes.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES).equals("true"));
    crashes.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && crashes.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES,
                        crashes.isChecked());
                crashes.setChecked(true);
                framework.startApplications();
                return true;
            }
            if (!isAccessibilityServiceActive()) {
                showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES, false);
            crashes.setChecked(false);
            return false;
        }
    });
    final CheckBoxPreference applications = (CheckBoxPreference) findPreference("status_applications");
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS).equals("true")
            && !isAccessibilityServiceActive()) {
        showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
        Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, false);
        framework.stopApplications();
    }
    applications.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS).equals("true"));
    applications.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (isAccessibilityServiceActive() && applications.isChecked()) {
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, true);
                applications.setChecked(true);
                framework.startApplications();
                return true;
            } else {
                if (!isAccessibilityServiceActive()) {
                    showDialog(Aware_Preferences.DIALOG_ERROR_ACCESSIBILITY);
                }

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_APPLICATIONS, false);
                applications.setChecked(false);

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NOTIFICATIONS, false);
                notifications.setChecked(false);

                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_CRASHES, false);
                crashes.setChecked(false);

                framework.stopApplications();
                return false;
            }
        }
    });

    final EditTextPreference frequency_applications = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_APPLICATIONS);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS).length() > 0) {
        frequency_applications
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS)
                        + " seconds");
    }
    frequency_applications
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS));
    frequency_applications.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_APPLICATIONS,
                    (String) newValue);
            frequency_applications.setSummary((String) newValue + " seconds");
            framework.startApplications();
            return true;
        }
    });

    final CheckBoxPreference installations = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_INSTALLATIONS);
    installations.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_INSTALLATIONS).equals("true"));
    installations.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_INSTALLATIONS,
                    installations.isChecked());
            if (installations.isChecked()) {
                framework.startInstallations();
            } else {
                framework.stopInstallations();
            }
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Network module settings UI/*www  .  j a  va  2 s .  c  o  m*/
 */
private void network() {
    final CheckBoxPreference network_traffic = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_NETWORK_TRAFFIC);
    network_traffic.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_NETWORK_TRAFFIC).equals("true"));
    network_traffic.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NETWORK_TRAFFIC,
                    network_traffic.isChecked());
            if (network_traffic.isChecked()) {
                framework.startTraffic();
            } else {
                framework.stopTraffic();
            }
            return true;
        }
    });

    final EditTextPreference frequencyTraffic = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_NETWORK_TRAFFIC);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_NETWORK_TRAFFIC).length() > 0) {
        frequencyTraffic.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_NETWORK_TRAFFIC)
                        + " seconds");
    }
    frequencyTraffic
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_NETWORK_TRAFFIC));
    frequencyTraffic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_NETWORK_TRAFFIC,
                    (String) newValue);
            frequencyTraffic.setSummary((String) newValue + " seconds");
            if (network_traffic.isChecked()) {
                framework.startTraffic();
            }
            return true;
        }
    });

    final CheckBoxPreference network = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_NETWORK_EVENTS);
    network.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_NETWORK_EVENTS).equals("true"));
    network.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_NETWORK_EVENTS,
                    network.isChecked());
            if (network.isChecked()) {
                framework.startNetwork();
            } else {
                framework.stopNetwork();
            }
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Light module settings UI//from w w  w.j av  a 2s.  c o m
 */
private void light() {

    final PreferenceScreen light_pref = (PreferenceScreen) findPreference("light");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT);
    if (temp != null) {
        light_pref.setSummary(
                light_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        light_pref.setSummary(light_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference light = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_LIGHT);
    light.setChecked(Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT).equals("true"));
    light.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_LIGHT) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                light.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_LIGHT, light.isChecked());
            if (light.isChecked()) {
                framework.startLight();
            } else {
                framework.stopLight();
            }
            return true;
        }
    });

    final EditTextPreference frequency_light = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_LIGHT);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT).length() > 0) {
        frequency_light.setSummary(
                Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT) + " microseconds");
    }
    frequency_light.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT));
    frequency_light.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_LIGHT, (String) newValue);
            frequency_light.setSummary((String) newValue + " microseconds");
            framework.startLight();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Gravity module settings UI//from  www . j a va 2 s .  c om
 */
private void gravity() {
    final PreferenceScreen grav_pref = (PreferenceScreen) findPreference("gravity");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY);
    if (temp != null) {
        grav_pref.setSummary(
                grav_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        grav_pref.setSummary(grav_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference gravity = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_GRAVITY);
    gravity.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY).equals("true"));
    gravity.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_GRAVITY) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                gravity.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, false);
                return false;
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GRAVITY, gravity.isChecked());
            if (gravity.isChecked()) {
                framework.startGravity();
            } else {
                framework.stopGravity();
            }
            return true;
        }
    });

    final EditTextPreference frequency_gravity = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_GRAVITY);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY).length() > 0) {
        frequency_gravity
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY)
                        + " microseconds");
    }
    frequency_gravity.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY));
    frequency_gravity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GRAVITY, (String) newValue);
            frequency_gravity.setSummary((String) newValue + " microseconds");
            framework.startGravity();
            return true;
        }
    });
}

From source file:com.aware.Aware_Preferences.java

/**
 * Atmospheric Pressure module settings UI
 *///from www  .  j  av  a 2  s .c o m
private void barometer() {
    final PreferenceScreen baro_pref = (PreferenceScreen) findPreference("barometer");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_PRESSURE);
    if (temp != null) {
        baro_pref.setSummary(
                baro_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        baro_pref.setSummary(baro_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference pressure = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_BAROMETER);
    pressure.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_BAROMETER).equals("true"));
    pressure.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_PRESSURE) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                pressure.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BAROMETER, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_BAROMETER, pressure.isChecked());
            if (pressure.isChecked()) {
                framework.startBarometer();
            } else {
                framework.stopBarometer();
            }
            return true;
        }
    });

    final EditTextPreference frequency_pressure = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_BAROMETER);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BAROMETER).length() > 0) {
        frequency_pressure
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BAROMETER)
                        + " microseconds");
    }
    frequency_pressure
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BAROMETER));
    frequency_pressure.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_BAROMETER, (String) newValue);
            frequency_pressure.setSummary((String) newValue + " microseconds");
            framework.startBarometer();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Rotation module settings UI//from w w w . j a  v  a2s.co  m
 */
private void rotation() {

    final PreferenceScreen rotation_pref = (PreferenceScreen) findPreference("rotation");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
    if (temp != null) {
        rotation_pref.setSummary(
                rotation_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        rotation_pref.setSummary(rotation_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference rotation = (CheckBoxPreference) findPreference(Aware_Preferences.STATUS_ROTATION);
    rotation.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION).equals("true"));
    rotation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                rotation.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_ROTATION, rotation.isChecked());
            if (rotation.isChecked()) {
                framework.startRotation();
            } else {
                framework.stopRotation();
            }
            return true;
        }
    });

    final EditTextPreference frequency_rotation = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_ROTATION);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION).length() > 0) {
        frequency_rotation
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION)
                        + " microseconds");
    }
    frequency_rotation.setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION));
    frequency_rotation.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ROTATION, (String) newValue);
            frequency_rotation.setSummary((String) newValue + " microseconds");
            framework.startRotation();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Gyroscope module settings UI/*from ww w .jav  a 2  s.  c  om*/
 */
private void gyroscope() {
    final PreferenceScreen gyro_pref = (PreferenceScreen) findPreference("gyroscope");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    if (temp != null) {
        gyro_pref.setSummary(
                gyro_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        gyro_pref.setSummary(gyro_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference gyroscope = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_GYROSCOPE);
    gyroscope.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_GYROSCOPE).equals("true"));
    gyroscope.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                gyroscope.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GYROSCOPE, false);
                return false;
            }
            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_GYROSCOPE,
                    gyroscope.isChecked());
            if (gyroscope.isChecked()) {
                framework.startGyroscope();
            } else {
                framework.stopGyroscope();
            }
            return true;
        }
    });

    final EditTextPreference frequency_gyroscope = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_GYROSCOPE);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GYROSCOPE).length() > 0) {
        frequency_gyroscope
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GYROSCOPE)
                        + " microseconds");
    }
    frequency_gyroscope
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GYROSCOPE));
    frequency_gyroscope.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_GYROSCOPE, (String) newValue);
            frequency_gyroscope.setSummary((String) newValue + " microseconds");
            framework.startGyroscope();
            return true;
        }
    });

}

From source file:com.aware.Aware_Preferences.java

/**
 * Proximity module settings UI/*from w ww  .  jav a2  s  . c  o m*/
 */
private void proximity() {

    final PreferenceScreen proxi_pref = (PreferenceScreen) findPreference("proximity");
    Sensor temp = mSensorMgr.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
    if (temp != null) {
        proxi_pref.setSummary(
                proxi_pref.getSummary().toString().replace("*", " - Power: " + temp.getPower() + " mA"));
    } else {
        proxi_pref.setSummary(proxi_pref.getSummary().toString().replace("*", ""));
    }

    final CheckBoxPreference proximity = (CheckBoxPreference) findPreference(
            Aware_Preferences.STATUS_PROXIMITY);
    proximity.setChecked(
            Aware.getSetting(getApplicationContext(), Aware_Preferences.STATUS_PROXIMITY).equals("true"));
    proximity.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            if (mSensorMgr.getDefaultSensor(Sensor.TYPE_PROXIMITY) == null) {
                showDialog(DIALOG_ERROR_MISSING_SENSOR);
                proximity.setChecked(false);
                Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_PROXIMITY, false);
                return false;
            }

            Aware.setSetting(getApplicationContext(), Aware_Preferences.STATUS_PROXIMITY,
                    proximity.isChecked());
            if (proximity.isChecked()) {
                framework.startProximity();
            } else {
                framework.stopProximity();
            }
            return true;
        }
    });

    final EditTextPreference frequency_proximity = (EditTextPreference) findPreference(
            Aware_Preferences.FREQUENCY_PROXIMITY);
    if (Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROXIMITY).length() > 0) {
        frequency_proximity
                .setSummary(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROXIMITY)
                        + " microseconds");
    }
    frequency_proximity
            .setText(Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROXIMITY));
    frequency_proximity.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            Aware.setSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_PROXIMITY, (String) newValue);
            frequency_proximity.setSummary((String) newValue + " microseconds");
            framework.startProximity();
            return true;
        }
    });
}