Chapter 16. Accelerometer

Accelerometers are one of the more interesting bits of hardware in smartphones. Earlier devices such as the Openmoko Neo FreeRunner smartphone and the original Apple iPhone included them. Before Android was released I was advocating for Openmoko at open source conferences.

One of my favorite imaginary applications was private key generation. Adhering to the theory that “When privacy is outlawed, only outlaws will have privacy,” several people were talking about this as early as 2008 (when I presented the idea at the Ontario Linux Fest). The idea is: if you can’t or don’t want to exchange private keys over a public channel, you meet on a street corner and shake hands—with each hand having a cell phone concealed in the palm. The devices are touching each other, thus their sensors should record exactly the same somewhat random motions. With a bit of mathematics to filter out the leading and trailing motion of the hands moving together, both devices should have quite a few bits’ worth of identical, random data that nobody else has—just what you need for crypto key exchange. I’ve yet to see anybody implement this, but I must admit I still hope somebody will come through.

Meanwhile, we have many other recipes on accelerometers and other sensors in this chapter…

16.1 Checking for the Presence or Absence of a Sensor

Rachee Singh

Problem

You want to use a given sensor. Before using an Android device for a sensor-based application, you should ...

Get Android Cookbook, 2nd Edition 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.