May 102015

For a recent project, I had to create a game-style controller Android app that senses the phone’s tilt and uses it as an input. (image via SO)

To simplify the explanation, imagine a jet thruster game where the farther you tilt the phone back, the stronger the jet thrusters fire:

  • When the phone sits upright, the thrusters don’t fire at all
  • When the phone is tilted all the way back, the thrusters fire at full force

Going into it, I knew I would need to use Sensors, specifically something about the Accelerometer. Digging in a bit more, no amount of Googling/Stack searching provided me with exactly what I was looking for, so I figured I’d write it up here…

Initial search results:


My fully open-sourced solution lives here:

Specifically, check out

A few notes: