Chapter 16. Location and Map Applications

16.1. Introduction: Location-Aware Applications

Ian Darwin

Discussion

Not that long ago, GPS devices were either unavailable, expensive, or cumbersome. Today, almost every smartphone has a GPS receiver, and many digital cameras do too. GPS is well on its way to becoming truly ubiquitous in devices. The organizations that provide map data have not been unaware of this trend. Indeed, OpenStreetMap exists and provides its “free, editable map of the world” in part because of the rise of consumer GPS devices—most of its map data was provided by enthusiasts. Google gets much of its data from commercial mapping services, but in Android, Google has been very driven by the availability of GPS receivers in Android devices. This chapter thus concentrates on the ins and outs of using Google Maps and OpenStreetMap in Android devices.

16.2. Getting Location Information

Ian Darwin

Problem

You just want to know where you are.

Solution

Use Android’s built-in location providers.

Android provides two levels of locational position. If you need to know fairly precisely where you are, you can use the FINE resolution, which is GPS-based. If you only need to know roughly where you are, you can use the COARSE resolution, which is based on the location of the cell phone tower(s) your phone is talking to or in range of. The fine resolution is usually accurate to a few meters; the coarse resolution may be accurate down to the building or city block in densely built-up areas, ...

Get Android Cookbook 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.