Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; public class Main { public static AlertDialog createErrorDialog(final Activity activity, String title, String message, final boolean doFinish) { final AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setMessage(message); builder.setTitle(title); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (doFinish) { activity.finish(); } } }); return builder.create(); } }