Answer the question
In order to leave comments, you need to log in
Why doesn't the onBackPressed override work?
I override onBackPressed in the main Activity.
public void onBackPressed() {
new AlertDialog.Builder(this)
.setTitle("Exit the app?")
.setMessage("Are you sure you want to exit?")
.setNegativeButton(android.R.string.no, null)
.setPositiveButton( android.R.string.yes, new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
finish();
}
}).create().show();
}
But it exits without any dialog creation, etc.
What is the problem?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question