Hey Mark,
  well, if just sending a toast from any thread I get this:

java.lang.RuntimeException: Can't create handler inside thread that has not
called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.widget.Toast.<init>(Toast.java:397)
at android.widget.Toast.makeText(Toast.java:230)

  When asking the original initiator of the background operation to pass in
a handler, it might happen, that the activity that created the handler is no
longer active when the operation finished. I also believe to remember that
this will bring out an exception too.

  All that looks very ugly, which often means that I don't get what the
proper way of doing things around here is.

  But if the above mentioned way (passing in a handler from the original
activity) is the best way, then I will just do that.

Cheers,
Mariano

On Fri, May 1, 2009 at 7:44 PM, Mark Murphy <[email protected]> wrote:

>
> Mariano Kamp wrote:
> >   what is a good way to signal an error from a thread that is not the UI
> > thread and you don't know which activity/handler is currently active?
>
> Does it matter?
>
> I have not tried to have a background thread use a Handler or
> runOnUiThread() of an Activity that might not be active. It is entirely
> possible "it just works", and so you can use whatever Activity you have
> handy.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android App Developer Books: http://commonsware.com/books.html
>
> >
>

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