Looking for New Results

Your service will be polling for new results, so it will need to know what the last result fetched was. This is a perfect job for another SharedPreferences entry.

Update QueryPreferences to store the ID of the most recently fetched photo.

Listing 26.6  Adding recent ID preference constant (QueryPreferences.java)

p​u​b​l​i​c​ ​c​l​a​s​s​ ​Q​u​e​r​y​P​r​e​f​e​r​e​n​c​e​s​ ​{​

 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​P​R​E​F​_​S​E​A​R​C​H​_​Q​U​E​R​Y​ ​=​ ​"​s​e​a​r​c​h​Q​u​e​r​y​"​;​
 ​ ​ ​ ​p​r​i​v​a​t​e​ ​s​t​a​t​i​c​ ​f​i​n​a​l​ ​S​t​r​i​n​g​ ​P​R​E​F​_​L​A​S​T​_​R​E​S​U​L​T​_​I​D​ ​=​ ​"​l​a​s​t​R​e​s​u​l​t​I​d​"​;​ ​ ​ ​ ​p​u​b​l​i​c​ ​s​t​a​t​i​c​ ​S​t​r​i​n​g​ ​g​e​t​S​t​o​r​e​d​Q​u​e​r​y​(​C​o​n​t​e​x​t​ ...

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.