O'Reilly logo

Beginning Android Tablet Games Programming by Jeremy Kerfs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required