In this tutorial you will learn how to make a alert dialog box in android. here, we will open this alert dialog when a button is clicked or back button is pressed. As you see in snapshot it is asking for confirmation "Yes" or "No", So i have also added a toast when the button is clicked.
So, lets start with creating a new project :
Step 1 : Open your activity_main.xml and add a button as given below in the code: