Documentation
¶
Overview ¶
Example: accelerometer sensor detail and event-queue setup.
Obtains the default accelerometer, prints its detailed properties, and documents how to set up an event queue for continuous reading.
The Android sensor API requires an ALooper for the event queue. The typical pattern is:
- Prepare a looper on the current thread (looper.Prepare).
- Create an event queue via the sensor manager, passing the looper.
- Enable the sensor on the queue and set a sampling rate.
- Poll the looper; when data is ready, read events from the queue.
- Disable the sensor and destroy the queue on cleanup.
This example focuses on sensor querying and shows the event-queue setup pattern in commented code. The event-reading loop is a sketch because it requires a running Android looper thread.
This program must run on an Android device.
Click to show internal directories.
Click to hide internal directories.