Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.widget.Toast; public class Main { public static void raiseToastAlertRunningOnUIThread(final String message, final Activity activity) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText((Context) activity, message, Toast.LENGTH_LONG).show(); } }); } }