Faster Answers: the Last Known Location
There are times when your users do not want to sit and wait for several minutes for their device to communicate with mysterious satellites in space just to find out where they are. Fortunately, with a little more work, you can prevent them from having to wait by using the LocationManager’s last known location for any location provider.
Since you are using the GPS provider only, it makes the most sense to ask for its last known location, and doing so is rather straightforward. The only other trick is getting that location back to the user interface, and for that you can simply broadcast an Intent just as though you were the LocationManager.
Listing 33.10 Getting the last known location (RunManager.java)
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