July 2015
Beginner to intermediate
600 pages
18h 59m
English
Now that you have a location fix, it is time to use it. Write an async task to find a GalleryItem near your location fix, download its associated image, and display it.
Put this code inside a new inner AsyncTask called SearchTask. Start by performing the search, selecting the first GalleryItem that comes up.
Listing 31.17 Writing SearchTask (LocatrFragment.java)
private void findImage() {
...
LocationServices.FusedLocationApi
.requestLocationUpdates(mClient, request, new LocationListener() {
@Override
public void onLocationChanged(Location location) {
Log.i(TAG, "Got a fix: " + location);
new SearchTask().execute(location);
}
});
}
private class SearchTask extends AsyncTask<Location,Void,Void> {
private ...Read now
Unlock full access