Java tutorial
//package com.java2s; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { public static void showMessageDialogWithFinish(final Activity object, Context context, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message).setCancelable(false).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { object.finish(); } }); AlertDialog alert = builder.create(); alert.show(); } }