I am trying to prevent an AlertDialog box from closing when pressing the back button in Android. I have followed both of the popular methods in this thread, and with System.out.println I can see that in both cases the code executes. However, the back button still closes the dialog box.
What could I be doing wrong? Ultimately I'm trying to prevent the back button closing a dialog box - it is a disclaimer that is displayed the first time the app is run and I don't want the user to have any option but to press the "Accept" button in order for the app to continue.
BACK
button then make sure your license/disclaimer dialog appears again next time they start the app and again and again until they either accept or remove the app from their device. If you choose to use the approach suggested by Sam then you MUST provide a 'Refuse' button but then re-create the license/disclaimer next time they start the app.Toast
, leave them locked in and rely on them using thwHOME
button to get out.