Here is a great blog post showing how to override the default action of the back button.
This can be very handy when interacting with pop-ups and dialogs within your app. For example, you may have a pop-up menu that you want the user to be able to back out of using the back button. Depending on your app’s design, the standard back button action might go so far as to exit the app. By overriding the standard action, the user could close the dialog instead.
Code samples are included in the post.