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 ...
Get Beginning Android Tablet Games Programming 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.