Here you can find the source of showToastInThread(final Context context, final String msg)
public static void showToastInThread(final Context context, final String msg)
//package com.java2s; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.widget.Toast; public class Main { public static void showToastInThread(final Context context, final String msg) { Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { showToast(context, msg); }// w w w . j a v a2 s .co m }); } public static void showToast(Context context, String msg) { Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); } }