Responding to Sensor Data
Android provides a simple way to acquire touch events, but sensors are a more complicated matter. This isn’t to say that getting the data is tricky or difficult, but working with the input in a meaningful way can be a real challenge. You concentrate on accelerometer data here because it’s the most commonly used sensor, and the other sensors (such as the gyroscope) are akin to it.
The data that tablet sensors deliver is very precise and usually of the Java long floating-point data type. This is a mixed blessing because long floating-point data is convoluted and complicated to figure out. Making things more difficult is the fact that tablets can be held in a variety of orientations. Holding the tablet in portrait mode ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access