SensorEventListener.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 */
23public interface SensorEventListener {
24
25    /**
26     * Called when sensor values have changed.
27     * <p>See {@link android.hardware.SensorManager SensorManager}
28     * for details on possible sensor types.
29     * <p>See also {@link android.hardware.SensorEvent SensorEvent}.
30     *
31     * <p><b>NOTE:</b> The application doesn't own the
32     * {@link android.hardware.SensorEvent event}
33     * object passed as a parameter and therefore cannot hold on o it.
34     * The object may be part of an internal pool and may be reused by
35     * the framework.
36     *
37     * @param event the {@link android.hardware.SensorEvent SensorEvent}.
38     */
39    public void onSensorChanged(SensorEvent event);
40
41    /**
42     * Called when the accuracy of a sensor has changed.
43     * <p>See {@link android.hardware.SensorManager SensorManager}
44     * for details.
45     *
46     * @param accuracy The new accuracy of this sensor
47     */
48    public void onAccuracyChanged(Sensor sensor, int accuracy);
49}
50