I\'m writing an application which will have two Activities, when the user presses the back button on the second activity a dialog should pop up asking the user to confirm th
As schwiz pointed out, you'll want to override the onBackPressed()
method in your activity class (http://developer.android.com/reference/android/app/Activity.html#onBackPressed()).
I just wanted to add that if you did want to at some stage continue with or access the standard the back operation (after say, displaying a dialog), then you simply call super.onBackPressed()
or ActivityName.super.onBackPressed()
from anywhere in the Activity.