SensorListener.java revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1/* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.hardware; 18 19/** 20 * Used for receiving notifications from the SensorManager when 21 * sensor values have changed. 22 * 23 * This interface is deprecated, use 24 * {@link android.hardware.SensorEventListener SensorEventListener} instead. 25 * 26 */ 27@Deprecated 28public interface SensorListener { 29 30 /** 31 * <p>Called when sensor values have changed. 32 * The length and contents of the values array vary 33 * depending on which sensor is being monitored. 34 * See {@link android.hardware.SensorManager SensorManager} 35 * for details on possible sensor types. 36 * 37 * <p><u>Definition of the coordinate system used below.</u><p> 38 * <p>The X axis refers to the screen's horizontal axis 39 * (the small edge in portrait mode, the long edge in landscape mode) and 40 * points to the right. 41 * <p>The Y axis refers to the screen's vertical axis and points towards 42 * the top of the screen (the origin is in the lower-left corner). 43 * <p>The Z axis points toward the sky when the device is lying on its back 44 * on a table. 45 * <p> <b>IMPORTANT NOTE:</b> The axis <b><u>are swapped</u></b> when the 46 * device's screen orientation changes. To access the unswapped values, 47 * use indices 3, 4 and 5 in values[]. 48 * 49 * <p>{@link android.hardware.SensorManager#SENSOR_ORIENTATION SENSOR_ORIENTATION}, 50 * {@link android.hardware.SensorManager#SENSOR_ORIENTATION_RAW SENSOR_ORIENTATION_RAW}:<p> 51 * All values are angles in degrees. 52 * 53 * <p>values[0]: Azimuth, rotation around the Z axis (0<=azimuth<360). 54 * 0 = North, 90 = East, 180 = South, 270 = West 55 * 56 * <p>values[1]: Pitch, rotation around X axis (-180<=pitch<=180), with positive 57 * values when the z-axis moves toward the y-axis. 58 * 59 * <p>values[2]: Roll, rotation around Y axis (-90<=roll<=90), with positive values 60 * when the z-axis moves toward the x-axis. 61 * 62 * <p>Note that this definition of yaw, pitch and roll is different from the 63 * traditional definition used in aviation where the X axis is along the long 64 * side of the plane (tail to nose). 65 * 66 * <p>{@link android.hardware.SensorManager#SENSOR_ACCELEROMETER SENSOR_ACCELEROMETER}:<p> 67 * All values are in SI units (m/s^2) and measure contact forces. 68 * 69 * <p>values[0]: force applied by the device on the x-axis 70 * <p>values[1]: force applied by the device on the y-axis 71 * <p>values[2]: force applied by the device on the z-axis 72 * 73 * <p><u>Examples</u>: 74 * <li>When the device is pushed on its left side toward the right, the 75 * x acceleration value is negative (the device applies a reaction force 76 * to the push toward the left)</li> 77 * 78 * <li>When the device lies flat on a table, the acceleration value is 79 * {@link android.hardware.SensorManager#STANDARD_GRAVITY -STANDARD_GRAVITY}, 80 * which correspond to the force the device applies on the table in reaction 81 * to gravity.</li> 82 * 83 * <p>{@link android.hardware.SensorManager#SENSOR_MAGNETIC_FIELD SENSOR_MAGNETIC_FIELD}:<p> 84 * All values are in micro-Tesla (uT) and measure the ambient magnetic 85 * field in the X, Y and -Z axis. 86 * <p><b><u>Note:</u></b> the magnetic field's Z axis is inverted. 87 * 88 * @param sensor The ID of the sensor being monitored 89 * @param values The new values for the sensor. 90 */ 91 public void onSensorChanged(int sensor, float[] values); 92 93 /** 94 * Called when the accuracy of a sensor has changed. 95 * See {@link android.hardware.SensorManager SensorManager} 96 * for details. 97 * 98 * @param sensor The ID of the sensor being monitored 99 * @param accuracy The new accuracy of this sensor. 100 */ 101 public void onAccuracyChanged(int sensor, int accuracy); 102} 103