Lines Matching refs:Sensor
23 import android.hardware.Sensor;
41 * Encapsulates a sensor.
44 /** Sensor to monitor. */
45 private final Sensor mSensor;
46 /** Check box representing the sensor on the screen. */
48 /** Text view displaying the value of the sensor. */
56 * @param sensor Sensor to monitor.
58 MonitoredSensor(Sensor sensor) {
59 mSensor = sensor;
61 // Add a row representing this sensor on the display
66 // Initialize displayed checkbox for this sensor, and register
70 // Initialize displayed text box for this sensor.
74 // Set appropriate sensor name depending on the type. Unfortunately,
75 // we can't really use sensor.getName() here, since the value it
78 // display sensor's value, and strings that are sent to the
80 switch (sensor.getType()) {
81 case Sensor.TYPE_ACCELEROMETER:
86 case 9: // Sensor.TYPE_GRAVITY is missing in API 7
91 case Sensor.TYPE_GYROSCOPE:
96 case Sensor.TYPE_LIGHT:
101 case 10: // Sensor.TYPE_LINEAR_ACCELERATION is missing in API 7
106 case Sensor.TYPE_MAGNETIC_FIELD:
111 case Sensor.TYPE_ORIENTATION:
116 case Sensor.TYPE_PRESSURE:
121 case Sensor.TYPE_PROXIMITY:
126 case 11: // Sensor.TYPE_ROTATION_VECTOR is missing in API 7
131 case Sensor.TYPE_TEMPERATURE:
144 * Gets sensor type.
146 * @return Sensor type as one of the Sensor.TYPE_XXX constants.
153 * Starts monitoring the sensor. NOTE: This method is called from
162 * Stops monitoring the sensor. NOTE: This method is called from outside
171 * Handles "sensor changed" event. This is an implementation of the
176 // Display current sensor value, and format message that will be
193 * Handles "sensor accuracy changed" event. This is an implementation of
197 public void onAccuracyChanged(Sensor sensor, int accuracy) {
212 List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ALL);
215 Sensor avail_sensor = sensors.get(n);
219 // The first sensor we've got for the given type is not
220 // necessarily the right one. So, use the default sensor
222 Sensor def_sens = sm.getDefaultSensor(avail_sensor.getType());
232 * Checks if a sensor for the given type is already monitored.
234 * @param type Sensor type (one of the Sensor.TYPE_XXX constants)
235 * @return true if a sensor for the given type is already monitored, or
236 * false if the sensor is not monitored.