Location Sensors

Android devices typically have two location sensors. One sensor (network sensor) is based on the cell towers and/or the Wi-Fi access points your device is connected to. This sensor provides the approximate location of the device. The other sensor is based on a built-in Global Positioning System (GPS) receiver. This sensor can provide position information accurate to within a few meters, depending on conditions. However, the GPS sensor is much slower in acquiring its position information than the network sensor. Additionally, not all devices have a GPS sensor.

Location information is accessed within an app through the use of the LocationManager object. A LocationManager is not directly instantiated. It exists as an Android system ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android 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.