Stay organized with collections
Save and categorize content based on your preferences.
SensorEventListener
public
interface
SensorEventListener
android.hardware.SensorEventListener
|
Known indirect subclasses
|
Used for receiving notifications from the SensorManager when
there is new sensor data.
Summary
Public methods
onAccuracyChanged
public abstract void onAccuracyChanged (Sensor sensor,
int accuracy)
Called when the accuracy of the registered sensor has changed. Unlike
onSensorChanged(), this is only called when this accuracy value changes.
See the SENSOR_STATUS_* constants in
SensorManager
for details.
Parameters |
sensor |
Sensor |
accuracy |
int : The new accuracy of this sensor, one of
SensorManager.SENSOR_STATUS_* |
onSensorChanged
public abstract void onSensorChanged (SensorEvent event)
Called when there is a new sensor event. Note that "on changed"
is somewhat of a misnomer, as this will also be called if we have a
new reading from a sensor with the exact same sensor values (but a
newer timestamp).
See SensorManager
for details on possible sensor types.
See also SensorEvent
.
NOTE: The application doesn't own the
event
object passed as a parameter and therefore cannot hold on to it.
The object may be part of an internal pool and may be reused by
the framework.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# SensorEventListener\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nSensorEventListener\n===================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/hardware/SensorEventListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\n\n\ninterface\nSensorEventListener\n`\n\n\n`\n\n\n`\n\n|--------------------------------------|\n| android.hardware.SensorEventListener |\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [SensorEventCallback](/reference/android/hardware/SensorEventCallback), [SensorEventListener2](/reference/android/hardware/SensorEventListener2) |--------------------------------------------------------------------------|-----------------------------------------------------------------------------------| | [SensorEventCallback](/reference/android/hardware/SensorEventCallback) | Used for receiving sensor additional information frames. | | [SensorEventListener2](/reference/android/hardware/SensorEventListener2) | Used for receiving a notification when a flush() has been successfully completed. | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nUsed for receiving notifications from the SensorManager when\nthere is new sensor data.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onAccuracyChanged](/reference/android/hardware/SensorEventListener#onAccuracyChanged(android.hardware.Sensor,%20int))`(`[Sensor](/reference/android/hardware/Sensor)` sensor, int accuracy) ` Called when the accuracy of the registered sensor has changed. |\n| ` abstract void` | ` `[onSensorChanged](/reference/android/hardware/SensorEventListener#onSensorChanged(android.hardware.SensorEvent))`(`[SensorEvent](/reference/android/hardware/SensorEvent)` event) ` Called when there is a new sensor event. |\n\nPublic methods\n--------------\n\n### onAccuracyChanged\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onAccuracyChanged (Sensor sensor, \n int accuracy)\n```\n\nCalled when the accuracy of the registered sensor has changed. Unlike\nonSensorChanged(), this is only called when this accuracy value changes.\n\nSee the SENSOR_STATUS_\\* constants in\n[SensorManager](/reference/android/hardware/SensorManager) for details.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|---------------------------------------------------------------------------------------|\n| `sensor` | `Sensor` \u003cbr /\u003e |\n| `accuracy` | `int`: The new accuracy of this sensor, one of `SensorManager.SENSOR_STATUS_*` \u003cbr /\u003e |\n\n### onSensorChanged\n\nAdded in [API level 3](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onSensorChanged (SensorEvent event)\n```\n\nCalled when there is a new sensor event. Note that \"on changed\"\nis somewhat of a misnomer, as this will also be called if we have a\nnew reading from a sensor with the exact same sensor values (but a\nnewer timestamp).\n\nSee [SensorManager](/reference/android/hardware/SensorManager)\nfor details on possible sensor types.\n\nSee also [SensorEvent](/reference/android/hardware/SensorEvent).\n\n**NOTE:** The application doesn't own the\n[event](/reference/android/hardware/SensorEvent)\nobject passed as a parameter and therefore cannot hold on to it.\nThe object may be part of an internal pool and may be reused by\nthe framework.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-----------------------------------------------------------------------------------|\n| `event` | `SensorEvent`: the [SensorEvent](/reference/android/hardware/SensorEvent). \u003cbr /\u003e |"]]