The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


The Fused Location Provider

At the 2013 Google I|O conference, Google announced an update to Google Play Services that offers a “fused location provider”, one that seamlessly uses all available location data to give you as accurate of a location as possible, as quickly as possible, with as little power consumption as possible. This serves as an adjunct to the traditional LocationManager approach for finding one’s position. The fused location provider has a different API, though one that is similar in some respects to the LocationManager API. However, this provider is part of the Play Services SDK, not part of Android itself.

In this chapter, we will examine how to use the fused location provider, in its latest incarnation, sporting a new API that debuted in 2017.

Prerequisites

This chapter assumes that you have read the preceding chapter on location-based services, along with that chapter’s prerequisites.

Why Use the Fused Location Provider?

The traditional recipes for using location providers are a bit complicated, if you want to maximize results. Simply asking for a GPS fix is not that hard, but:

The fused location provider is designed to address these sorts of concerns. Its implementation will blend data from GPS, cell tower triangulation, and WiFi hotspot proximity to determine the device’s location, without your having to manually set all of that up. The fused location provider will also take advantage of sensor data, so it does not try to update your location as frequently if the accelerometer indicates that you are not moving.

The net result is better location data, delivered more quickly, with (reportedly) less power consumption.

Why Not Use the Fused Location Provider?

The preview of this section was abducted by space aliens.

Finding Our Location, Once

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Getting Periodic Locations

The preview of this section may contain nuts.