accelerometer

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 3 Imported by: 0

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:

  1. Prepare a looper on the current thread (looper.Prepare).
  2. Create an event queue via the sensor manager, passing the looper.
  3. Enable the sensor on the queue and set a sampling rate.
  4. Poll the looper; when data is ready, read events from the queue.
  5. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL