Java tutorial
//package com.java2s; import android.app.Activity; import android.app.AlertDialog; public class Main { static public Activity activity; static public String tempTitle; static public String tempMessage; static public void ShowAlert(String title, String message) { tempTitle = title; tempMessage = message; activity.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle(tempTitle); alertDialog.setMessage(tempMessage); alertDialog.show(); } }); } }