Mariano Kamp wrote: > 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)
It looks like you are trying to manually instantiate a Handler, or possibly an Activity, in the background thread. If so, that is not the proper way to use a Handler. This is one of the reasons I dislike Handler, preferring runOnUiThread() (and hopefully the new AsyncTask). > 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. Doubtful. Otherwise, AsyncTask couldn't work. > 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. Can you use AsyncTask for this? The result of your background work would be passed to onPostExecute(), which could then display an error on the UI thread if something failed in the background thread. -- 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 -~----------~----~----~----~------~----~------~--~---

