Android Programming: The Big Nerd Ranch Guide, 2nd Edition
by Bill Phillips, Chris Stewart, Brian Hardy, Kristin Marsicano
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 31.14 Building a location request (LocatrFragment.java)
@Override ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access