views:

343

answers:

2

How can I display Toast messages from a thread?

A: 

Like this or this, with a Runnable that shows the Toast.

alex
+6  A: 

You can do it by calling an Activity's runOnUiThread method from your thread:

activity.runOnUiThread(new Runnable() {
    public void run() {
        Toast.makeText(activity, "Hello", Toast.LENGTH_SHORT).show();
    }
});
Lauri Lehtinen