Java tutorial
//package com.java2s; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { @SuppressWarnings("deprecation") public static void showAlert(final String title, final String msg, final Context context) { Activity a = (Activity) context; a.runOnUiThread(new Runnable() { @Override public void run() { AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(msg); alertDialog.setButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.cancel(); } }); alertDialog.show(); } }); } }