Thanks a ton you guys!  I was not aware of the ResultReceiver, which makes
things much cleaner.  I wish someone would create a nice graphic explaining
the patterns for communicating between UI and non-UI threads/processes.
 Moreover, it seems this only works where the Service is local to the app,
right?  The aforementioned graphic would rock if it also called out
inter/intra app differences.  Who would like to create this?  And while you
are painting this most useful masterpiece, perhaps you could overlay the
lifecycles too <wink>

Peace,
Scott Stanlick

On Mon, Feb 25, 2013 at 2:03 PM, Streets Of Boston
<[email protected]>wrote:

> Does your receiver handle the JSON update (i.e. it goes out to the server,
> retrieves the updated json from the server and notifies the registered
> activities)?
>
> If so, this is not correct. BroadcastReceivers should never ever do long
> running tasks.
> Instead, your BroadcastReceiver should receive the "synch.my.app" request.
> It then would start a Service (preferrably a wakefull IntentService) that
> does the actual work (since IntentServices can run for longer times). The
> IntentService then sends a "here.is.the.json" broadcast back, when it's
> done, to the registered activities.
>
> BTW: Instead of sending back "here.is.the.json" broadcasts, your calling
> Activity could add a ResultReceiver to the Intent. The BroadcastReceiver
> will send the Intent including this ResultReceiver to the IntentService.
> And when the IntentService is done, the IntentService could just call
> 'send(resultCode, resultData)' to update the calling Activity of the final
> result.
>
>
> On Monday, February 25, 2013 1:25:44 PM UTC-5, stanlick wrote:
>>
>> I have been experimenting with an easy way to execute "synch" type bursts
>> without all the hassle of Services, Loaders, Threads, etc.  I have come up
>> with a technique that works great, but I'd like to get a consensus
>> regarding the pattern.  I am performing sendBroadcast("synch.my.app") from
>> the activity needing an update.  This same activity is registering a
>> broadcast receiver registerReceiver(**payload, new
>> IntentFilter("here.is.the.**json")) which is being notified from the
>> "synch.my.app" receiver.  In other words, my broadcastreceiver is calling
>> me back once it has the data.  Is this crazy?  I'm simply poking my json
>> payload into the intent before sending broadcast back to activity.
>
>  --
> --
> 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
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Android Developers" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-developers/P3_LTy2sZaE/unsubscribe?hl=en
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
"As I grow older, I pay less attention to what men say. I just watch what
they do." Andrew Carnegie

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to