Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When should I be using Service and BroadcastReceiver?

 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a bit of an android hobbyist, teaching myself as I go etc.

So far all my apps have been pretty simple, using a handful of activities to do basic tasks

My question is, what does the Service or BroadcastReceiver class/feature give me?

An example of one of my apps : 2 tabs, one shows contacts, the other shows them on the map. How would I benefit from service/broadcastreceivers here? I'm doing a geocoding call, should I migrate that over to the service?
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Service runs in the background and has no UI, so I don't see how it would help in the scenario you describe. See http://marakana.com/forums/android/examples/60.html for a Service example.

I'd say any background network calls that are triggered by user actions are candidates for implementation with an android.os.AsyncTask; writeup at http://developer.android.com/resources/articles/painless-threading.html
 
James Elsey
Ranch Hand
Posts: 228
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the links Lester, will give them a read tonight
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic