简体   繁体   中英

How to handle the application Back-Button in an Android app

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM