Arutha Arutha - 1 year ago 144
Android Question

Android: Toast in a thread

How can I display Toast messages from a thread?

Answer Source

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();
    }
});