O'Reilly logo

Android Programming: The Big Nerd Ranch Guide, Third Edition by Kristin Marsicano, Chris Stewart, Bill Phillips

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

Getting a Location Fix

Now that you have everything set up, you are ready to get a location fix. Your window to the Fused Location Provider API is a class named, appropriately enough, FusedLocationProviderApi. There is one instance of this class. It is a singleton object that lives on LocationServices called FusedLocationApi.

To get a location fix from this API, you need to build a location request. Fused location requests are represented by LocationRequest objects. Create one and configure it in a new method called findImage(). (There are two LocationRequest classes. Use the one with the complete name of com.google.android.gms.location.LocationRequest.)

Listing 33.14  Building a location request (LocatrFragment.java)

 @Override ...

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