简体   繁体   中英

What is the equivalent of onBackPressed() for overriding and taking control of the Recent Apps button on Android?

This is the method to access Android's Back button.

@Override
public void onBackPressed() {
// do something on back.
return;
}

I want to do something similar for the Recent Apps button (the right most one)

You can really change the functionality of the AppButton programatically except if you are creating your own custom launcher but you can still detect if the AppButton is pressed in your app.

sample:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);

    if(!hasFocus)
        Log.d("APP BUTTON", "APP BUTTON");
}

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