• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When should I be using Service and BroadcastReceiver?

 
Ranch Hand
Posts: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 231
Android IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the links Lester, will give them a read tonight
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic