Java tutorial
//package com.java2s; /* * * * (C) Copyright 2015 byteShaft Inc. * * * * All rights reserved. This program and the accompanying materials * * are made available under the terms of the GNU Lesser General Public License * * (LGPL) version 2.1 which accompanies this distribution, and is available at * * http://www.gnu.org/licenses/lgpl-2.1.html * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * */ import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Handler; public class Main { private static AlertDialog buildErrorDialog(final Activity context, String title, String description, String buttonText) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(title); builder.setMessage(description); builder.setCancelable(false); builder.setPositiveButton(buttonText, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { new Handler().post(new Runnable() { @Override public void run() { dialog.dismiss(); context.finish(); } }); } }); return builder.create(); } }