Skip to content Skip to sidebar Skip to footer

Toast From A Non-ui Thread

Possible Duplicate: Android: Toast in a thread I am calling a helper class function from a worker thread, wherein I am trying to raise a toast but I am getting following excepti

Solution 1:

You can use runOnUiThread() For example

this.runOnUiThread(show_toast);

and in show_toast

private Runnable show_toast = new Runnable()
{
    publicvoidrun()
    {
        Toast.makeText(Autoamtion.this, "My Toast message", Toast.LENGTH_SHORT)
                    .show();
    }
};

Post a Comment for "Toast From A Non-ui Thread"