Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.media.AudioManager; public class Main { public static void showDialogOkWithGoBack(String title, String message, final Activity activity) { if (activity.getApplicationContext() != null) { AlertDialog.Builder adb = new AlertDialog.Builder(activity); adb.setTitle(title); adb.setMessage(message); adb.setCancelable(false); adb.setNeutralButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); //activity.onBackPressed(); } }); AlertDialog ad = adb.create(); ad.setVolumeControlStream(AudioManager.STREAM_MUSIC); ad.show(); } } }