android - My Content Provider to Rest with Broadcast is having Infinite loop -


i watched virgil's android rest google io video , trying implement it.

in short problem please read on details.

contentresolver query -> content provider query -> start database update service, make query, return cursor

the service -> update database ->broadcast database update

activity -> register broadcast -> on receive contentresolver query. (we in beginning)

this became infinite loop.

in content provider, query method. start intent service uses rest service. query method queries local database , returns cursor. in onhandle() method of intent service, retrieve new content web service , writes database. send local broadcast action.

in activity register broadcast , onreceive(). call contentresolver.query new content database. apparently creating circular problem. in content provider query..service..broadcast.

i want able stop broadcast after received.

how can solve this. should use sqlitedatabase query rather content resolver? or should send broadcast differently. can send parameter content resolver query broadcastafterupdateon , off? should derive content resolver , create custom query method?

don't send notification if there no new item in rest result.

long id = db.insertwithonconflict(gettablename(), null, values, sqlitedatabase.conflict_ignore); if (id < 0) {   return null; } uri newuri = contenturis.withappendedid(getcontenturi(), values.getasinteger(getidfieldname())); log.d(tag, "new profile uri: " + newuri.tostring()); getcontext().getcontentresolver().notifychange(newuri, null); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -