Java tutorial
//package com.java2s; //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static void showAlertDialog(Context context, String title, String message) { AlertDialog dialog = new AlertDialog.Builder(context).create(); dialog.setCancelable(true); dialog.setMessage(message); dialog.setTitle(title); dialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog.show(); } }