I have a question about handling the application Back-Button in an Android app. Since this can be ambiguous, look at the screenshot below to know what I mean by "application Back-Button".
The left arrow at the top left of the picture is (what I mean by) the application Back-Button.
The little triangle on the left side at the bottom of the picture is (what I call here) the "phone Back-Button".
I have noticed that the onBackPressed() function is called when the phone Back-Button is touched. I need to know which function is called when the application Back-Button is touched.
CodePudding user response:
You can try to override fun onOptionsItemSelected and handle your logic. Hope it helpful!
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// handle arrow click here
return super.onOptionsItemSelected(item);
}