Java tutorial
//package com.java2s; //License from project: Apache License 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 String string) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { @Override public void run() { Toast.makeText(context, string, Toast.LENGTH_LONG).show(); } }); } }