diff options
author | Mathias Agopian <mathias@google.com> | 2010-08-25 14:35:54 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-08-25 14:35:54 -0700 |
commit | 43c87e44fc0d7d7b37e039752c0dec093e227381 (patch) | |
tree | 9360ea05e566f4955a8af66c162b6099ec18d4c1 /core/java/android/hardware/SensorManager.java | |
parent | 8395b4625b96f2133e2e4f595fdc69fbe222e4fc (diff) | |
download | frameworks_base-43c87e44fc0d7d7b37e039752c0dec093e227381.zip frameworks_base-43c87e44fc0d7d7b37e039752c0dec093e227381.tar.gz frameworks_base-43c87e44fc0d7d7b37e039752c0dec093e227381.tar.bz2 |
Improve Sensors documentation a bit
Change-Id: I6f4f9ebfaf1e7f461a795f717b9913e3a021e9d4
Diffstat (limited to 'core/java/android/hardware/SensorManager.java')
-rw-r--r-- | core/java/android/hardware/SensorManager.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/core/java/android/hardware/SensorManager.java b/core/java/android/hardware/SensorManager.java index 97921fe..0068724 100644 --- a/core/java/android/hardware/SensorManager.java +++ b/core/java/android/hardware/SensorManager.java @@ -34,11 +34,19 @@ import java.util.HashMap; import java.util.List; /** + * <p> * SensorManager lets you access the device's {@link android.hardware.Sensor * sensors}. Get an instance of this class by calling * {@link android.content.Context#getSystemService(java.lang.String) * Context.getSystemService()} with the argument * {@link android.content.Context#SENSOR_SERVICE}. + * </p> + * <p> + * Always make sure to disable sensors you don't need, especially when your + * activity is paused. Failing to do so can drain the battery in just a few + * hours. Note that the system will <i>not</i> disable sensors automatically when + * the screen turns off. + * </p> * * <pre class="prettyprint"> * public class SensorActivity extends Activity, implements SensorEventListener { @@ -48,13 +56,22 @@ import java.util.List; * public SensorActivity() { * mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); * mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); + * } + * + * protected void onResume() { + * super.onResume(); * mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); * } * + * protected void onPause() { + * super.onPause(); + * mSensorManager.unregisterListener(this); + * } + * * public void onAccuracyChanged(Sensor sensor, int accuracy) { * } * - * public abstract void onSensorChanged(SensorEvent event) { + * public void onSensorChanged(SensorEvent event) { * } * } * </pre> |