hm, to be safe i'd always go with 1). although in my memory it's more
that the async task *can* be killed, not necessarily at a time you
expect.

On Jul 12, 6:29 pm, Matt <[email protected]> wrote:
> Hello all.
>
> As you should know, you should not be running code that takes a long
> time to complete, such as a network download, in a BroadcastReceiver.
> The reason is that it is run on the "main thread" and will cause an
> ANR (Application Not Responding) if the code does not complete within
> a short amount of time.  The proper solution is to handle this long
> running code on a background thread.
>
> I've seen conflicting comments about whether or not it is safe to use
> an AsyncTask from a BroadcastReceiver (btw, an AppWidget is a child of
> BroadcastReceiver, so we can use the two terms interchangeably).  On
> the one hand, I've heard that you should only use a Service, because
> the thread forked by AsyncTask can be killed, along with the
> BroadcastReceiver thread, once the BroadcastReceiver's onReceive() is
> finished due to Android killing the process.  On the other hand, I've
> actually seen code that simply uses an AsynchTask from an AppWidget to
> download background data.
>
> If the first point is correct, then it would imply that the second
> point is incorrect... unless there is already an existing background
> service which keeps the process alive, which I don't know about.
>
> Thanks,
> -Matt

-- 
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