Here is the code to add something like in this image : a dialog (pop-up) with buttons in Android.

Normally, the user may come back to your application with the “back” button. I wanted it to be a dead-end dialog. My aim was to close the application if there is no Internet connexion at all.

In this example, I set a modal AlertDialog with a title, a message, and an “OK” button, which will close the application (my current activity and a service).

What makes it modal, which means the user can not go back to the application without pushing the “OK” button, is the setCancelable(boolean) function.

AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("No connection");
alertDialog.setMessage("Oxydroid a besoin d'une connexion à Internet. Veuillez vérifier vos paramètres.");
alertDialog.setCancelable(false);
alertDialog.setButton("OK",new OnClickListener() {
	public void onClick(DialogInterface dialog, int which) {
		stopService(new Intent(Oxydroid.this, PlayerService.class));
		Oxydroid.this.finish();
	}
});
alertDialog.show();

:)