O'Reilly logo

Android Cookbook, 2nd Edition by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 15. Location and Map Applications

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 are well aware 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.

15.1 Getting Location Information

Ian Darwin

Problem

You want to know where you are.

Solution

Use Android’s built-in location providers.

Discussion

Android provides two levels of location detection. 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 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, or to the nearest 5 or 10 kilometers in very lightly populated ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required