Hi,

   I have trouble getting my head around background activities and am  
wondering how to implement something like downloading the latest  
weather every 30 minutes?

   Here is a sketch, please let me know if that makes sense?

   (1) Implement the download logic.

   (2) Let the Alarm Manager schedule the delivery of an Intent every  
30 minutes

   (3) Build a BroadcastReceiver that listens to that Intent and as it  
is a BroadCastReveiver it can't bind to a Service ( I didn't really  
understand the documentation on that) it is not possible to access the  
interface of the Service. So startService() needs to be called instead  
with parameters that would need to be parsed in the startService  
method of the Service and dispatched to the actual method providing  
the service. That would at least work for calls without a return value.

   (4) Implement the actual method providing the service, call the  
download logic implemented in (1) and let it run in a separate thread.

   Does this make sense? And why would I need a service then? Why not  
instantiate the Runnable directly from the BroadCastReceiver?
In the actual case I am looking into I have a BroadcastReceiver, some  
Activities and some Threads and the whole communication between those  
won't cross process boundaries.

   And where would I track the state of the Runnable, i.e. that it is  
currently running / downloading stuff? As a static member of some  
class? As a static member of the Service?
And similar how to listen to a request to cancel the background  
operation, not necessarily the whole service, but this download? What  
seem to be best practices here?

Cheers,
Mariano

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to