android - General application design (IntentService/ContentProvider/AsyncTask) -


i'm trying figure out best general design applications access several web services , have multiple activities information displayed.

the way implemented latest android application following. have intentservice receives requests activities information web services. service notifies activities through resultreceiver status of request (started/error/finished). after calling web service, getting result(xml/json) , parsing it, put information in contentprovider (backed sqlite database) , use contentresolver notify activities changes. activities notified changes (some use contentobserver , others use simplecursoradapters , notified automatically).

now, problems approach:

  • every time enter activity, request info web service through method described above , delete rows in particular table, fill new info , notify activity. so, if user presses , enters again, whole dance again. think should add fields in database when last updated etc. don't know how proceed that. suggestions? think 1 alternative use alarms , trigger updates @ specific intervals. in case, specification asks check web service every time enter activity.
  • when call web service, show indeterminate progress bar in activity, on other views (which contain info fetched , sits in database until web service call finishes) user can start interacting views , not (the info may disappear database). way disable interaction? progressdialog comes mind.
  • if move through different activities, intentservice blocked previous web service calls , takes longer latest web service call. create multiple intentservice every web service don't think purpose.

i have feeling approach have taken not best 1 particular application. partially inspired google i/o application (i couldn't understand everything, updated sqlite fields etc.). 1 alternative have been use asynctasks in activities. can store info in order accessed other activities? in lists in application? , how id management?

i'm interested on opinions/ideas/suggestions , how can make next applications work better , more efficiently.

did check talk? http://www.youtube.com/watch?v=xhxn3kg2iqe

i found source of inspiration. basically, suggest build service helper (in case, service helper intent service) singleton class. can track ongoing requests

in way can track every different kind of ongoing background tasks performing, , block other request of same kind. example, if leave activity , enter activity b, , ask same web service query, can check still in progress because of activity a.

from saw on iosched app, suffers of problem if activity closed, fetch result gets lost.

there clear log says:

log.w(tag, "dropping result on floor code " + resultcode + ": " + resultdata.tostring());

i don't suggest using asynctask too, because result lost well.

however, take @ talk , slides.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -