Java tutorial
//package com.java2s; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.widget.Toast; public class Main { private static void showToast(final Context context, final int resId) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, resId, Toast.LENGTH_LONG).show(); } }); } }