Find and Display an Image

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)

p​r​i​v​a​t​e​ ​v​o​i​d​ ​f​i​n​d​I​m​a​g​e​(​)​ ​{​ ​ ​ ​ ​.​.​.​ ​ ​ ​ ​L​o​c​a​t​i​o​n​S​e​r​v​i​c​e​s​.​F​u​s​e​d​L​o​c​a​t​i​o​n​A​p​i​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​.​r​e​q​u​e​s​t​L​o​c​a​t​i​o​n​U​p​d​a​t​e​s​(​m​C​l​i​e​n​t​,​ ​r​e​q​u​e​s​t​,​ ​n​e​w​ ​L​o​c​a​t​i​o​n​L​i​s​t​e​n​e​r​(​)​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​@​O​v​e​r​r​i​d​e​ ...

Get Android Programming: The Big Nerd Ranch Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.