This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When should I be using Service and BroadcastReceiver?  RSS feed

 
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!