I have a Service that runs a distinct Thread to update a list based on 
external events.  This list is simultaneously used to back ListViews in 
associated Activities.  The Activities may also update the list based on UI 
events.

I need to provide appropriate synchronization.  I have coded a provision to 
send update events from the Service to the Activity(ies) via Message thru 
Handler.  Thus, I believe I can assure that the actual updates to the data 
in the list occur in the UI thread which should work properly when the 
Activity is running.

But when the Activity is not running for whatever reason (not started, 
destroyed, etc.), I need to have the Service update the list directly.  
This is not a problem either; the Activity can find the revised list 
content to create the ListView when it (re)starts.

But my problem is that I want to find a reasonable mechanism for all 
dynamic states, especially during transition, or in other words:

   - signal to the Service that the Activity is running and should be used 
   to process an update
      - in such case assure that the update completes (i.e. that the 
      Activity is not destroyed after the Message is passed, but before it is 
      processed)
   - otherwise signal that the Service must process the update in the 
   absence of the Activity
      - in such case assure that the Activity does not start and attempt to 
      build a ListView prior to list content update completion by the Service
   
I suspect this pattern of synchronization has been accomplished by others.  
Advice appreciated.


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


Reply via email to