android confirm dialog

Android confirm dialog box with OK and Cancel button

This will probably be one of the Android code snippets that I will need to go back to from time to time.

I’m sharing the codes we need to show an Android confirm dialog to prompt the user to click “yes” or “no”, or in my case, “OK” or “Cancel”.

The following code for Android confirm dialog is in my file:

Code snippet for “Android confirm dialog”

Run this on your Android phone or emulator. When you click OK or Cancel, you’ll see logs on Android Studio’s logcat “OK” or “Cancel”, whichever button you click.

The above code was adapted from (Android) Simple confirm dialog at, and then modified to work on my

By the way, I use Android Studio version 1.4 on Windows 7.

Related Posts:

Posts that may be related to "Android confirm dialog box with OK and Cancel button":


A Filipino programmer and baker. When I have time to spare, I blog, play video games, watch series (usually anime), cook dishes, draw, or spend a little time with pets. When I have the rare luxury of time, I get to travel and record song covers too! Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *