Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static AlertDialog genericOneButtonAlert(Context mContext, String title, String msg, String button) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mContext); alertDialogBuilder.setTitle(title); alertDialogBuilder.setMessage(msg).setCancelable(true).setPositiveButton(button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); //finish(); } }); // create alert dialog AlertDialog alertDialog = alertDialogBuilder.create(); // show it return alertDialog; } }