display Toast within Thread - Android android.widget

Android examples for android.widget:Toast

Description

display Toast within Thread

Demo Code

import android.app.Activity;
import android.widget.Toast;

public class Main {

  public static void displayToast(final Activity activity, final String text, final int duration) {
    activity.runOnUiThread(new Runnable() {

      public void run() {
        Toast toast = Toast.makeText(activity, text, duration);
        toast.show();//  w w  w.  j  a  v  a 2s .  co m

      }
    });
  }

}

Related Tutorials