Display Values from the Accelerometer
Let’s use the Ketai library to see what the accelerometer has to report. The accelerometer is the most common sensor found in mobile devices. It detects device acceleration and its orientation toward g-force. It returns the x-, y-, and z-axes of the device, measured in meters per second squared. These axes are not swapped when the app’s screen orientation changes.
The accelerometer sensor’s shortcomings are related to the fact that it cannot distinguish between rotation and movement. For instance, moving the device back and forth on a flat table and rotating it about its axes can produce identical accelerometer values. To differentiate between movement and rotation, we require an additional sensor, the ...
Get Rapid Android Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.