In this article, we are going to learn how to exit the application when clicking on the back press. If you didn't write this code for back press it will go to previous activity.