Java tutorial
//package com.java2s; import android.content.Context; import android.os.Handler; import android.widget.Toast; public class Main { private static Toast toast; private static Handler handler = new Handler(); public static void showToast(Context mContext, String text) { if (toast == null) { toast = Toast.makeText(mContext, text, Toast.LENGTH_SHORT); } else { toast.setText(text); } handler.post(new Runnable() { @Override public void run() { toast.show(); } }); } }