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 
17 package android.hardware;
18 
19 /**
20  * Used for receiving notifications from the SensorManager when
21  * there is new sensor data.
22  */
23 public interface SensorEventListener {
24 
25     /**
26      * Called when there is a new sensor event.  Note that "on changed"
27      * is somewhat of a misnomer, as this will also be called if we have a
28      * new reading from a sensor with the exact same sensor values (but a
29      * newer timestamp).
30      *
31      * <p>See {@link android.hardware.SensorManager SensorManager}
32      * for details on possible sensor types.
33      * <p>See also {@link android.hardware.SensorEvent SensorEvent}.
34      *
35      * <p><b>NOTE:</b> The application doesn't own the
36      * {@link android.hardware.SensorEvent event}
37      * object passed as a parameter and therefore cannot hold on to it.
38      * The object may be part of an internal pool and may be reused by
39      * the framework.
40      *
41      * @param event the {@link android.hardware.SensorEvent SensorEvent}.
42      */
onSensorChanged(SensorEvent event)43     public void onSensorChanged(SensorEvent event);
44 
45     /**
46      * Called when the accuracy of the registered sensor has changed.  Unlike
47      * onSensorChanged(), this is only called when this accuracy value changes.
48      *
49      * <p>See the SENSOR_STATUS_* constants in
50      * {@link android.hardware.SensorManager SensorManager} for details.
51      *
52      * @param accuracy The new accuracy of this sensor, one of
53      *         {@code SensorManager.SENSOR_STATUS_*}
54      */
onAccuracyChanged(Sensor sensor, int accuracy)55     public void onAccuracyChanged(Sensor sensor, int accuracy);
56 }
57