The Orientation Sensor

Nearly every Android device supports the useful Acceleration Sensor, but another sensor also gives you physical information. The Orientation Sensor tells how the phone is oriented relative to the Earth. This sensor provides roll, pitch, and azimuth data.

Imagine for a moment that the phone is an airplane (Figure 10.13). Looking at the phone as you normally would, the top (earpiece) would be the nose of the plane and the bottom (the home button and so on) would be the tail end. The roll is how much the plane rotates without the tail or nose moving, or how much the wings move up and down. The pitch is how much higher or lower the nose is than the tail.

Figure 10.13 Imagine that the phone is an airplane—the pitch and roll ...

Get Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps 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.