O'Reilly logo

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

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