Get Coordinates from the GPS Sensor

The network sensor uses cell towers and Wi-Fi access points to determine the device’s location. It is not as accurate as the GPS sensor, but it is faster. Additionally, it is available on all devices, whereas a GPS sensor is not. For this reason, it might make sense to begin the discussion of getting location from sensors with the network sensor. However, the network sensor cannot be tested on the emulator, whereas the GPS sensor can. Also, the code required to use both sensors is almost identical. For these reasons, the GPS sensor is discussed first.

To use the GPS sensor, you replace the Geocoding code in the Get Location button with GPS listener code. You also add a method to turn off the location sensing ...

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.