Sometimes, when developing Android applications, there is a need to override the default behaviour of the back button which means assigning another behavior for the ‘Back’ button. Although changing the behaviour of back button is not recommended, but there are some situations where changing the ‘back’ button behavior is mandatory, such as to avoid accidentally finishing or closing the current Activity.
For example, a text editor, should confirm if the user really wants to quit without saving the current changes, or a game, that check if it is the player’s intention to close the current game session.
We might have thought, how come when we click a button some action is performed in Android phone. Here in this post, we are going to discuss how to handle button events in Android.
Before proceed with the post, I would like to thank everyone who gave constant feedback for the past three posts. I expect everyone to let me know if you come across any difficulty while creating the application.
Please subscribe to this blog to keep getting updates when new post is added.
We are gonna develop a simple application which has one button that covers whole layout of the app. When you click/tap on the button, ‘Meow’ sound will be played, to be more appropriate we will keep ‘Cat’ image as background of the button. 🙂