简体   繁体   中英

Android onUserLeaveHint() in not called when back button is pressed

I am trying to implement PIP mode and to do so I am overriding onUserLeaveHint() to register events when the user is leaving the activity, but it is not called when the Back button is pressed, it only registers the home or recents button.

    protected void onUserLeaveHint() {
        super.onUserLeaveHint();
        if (usePipMode){
            setUpPipMode();
        }
    }

So, My Question is, Is it possible to register the back button press in onUserLeaveHint(), and if so please provide some code sample. It would be much helpful.

Thanks.

You can do it with onBackPressed method

@Override
public void onBackPressed() {
   onUserLeaveHint()
}

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