Phone Gap Chapter 7:Accessing the Device Sensors and Locations API
Cross-Platform Mobile App Development
CpSc 215
In this chapter, the author begins to assume a full walkthrough is not necessary and things start to vary more for individual devices. (That means finding the API for the device of interest, when necesssary.)
We can safely (cross-platform) use:
- the accelerometer
- Provides current acceleration along x, y & z axis (including gravity, 9.8 m/s2).
- For more info, see p. 184
- the compass
- Providing direction of travel
- device orientation
- Determined from accelerometer values or from browser media queries
- GPS (location)
- Location is determined in a number of way ranging from your current IP address (probably leading back to simply SRU) to GPS. The latter is typically accurate within 60 meters.
To see what else is available on Android, download the (non-PhoneGap) app "Android Sensor Box".
Examples for this chapter:
- Device orientation – Rotating rectangle
- Compass – great when you get lost in the forest (actually used in map-routing apps)
- Geolocation – the key datum in map-routing app
- The author's example even pulls up a Google map, but that requires a "free" account. I use a standard web page search for Google, which means
- In-App browser (p. 216 in text)