简体   繁体   English

在Android上覆盖和控制“最近使用的应用程序”按钮时,onBackPressed()等效于什么?

[英]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. 这是访问Android的“后退”按钮的方法。

@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. 您可以AppButton编程方式真正地更改AppButton的功能,除非您正在创建自己的自定义启动器,但是您仍然可以检测是否在应用程序中按下了AppButton

sample: 样品:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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