如何在 android 中按后退按钮或主页按钮最小化应用程序

问题描述 投票:0回答:1

我想在按下后退按钮或主页按钮时显示特定大小的应用程序。

java android minimize onbackpressed
1个回答
-1
投票

下面的代码演示了如何在用户按下返回按钮时模拟主页按钮按下,在我看来,将返回事件视为主页事件是必要的。

 public void minimizeApp() 
 {
    Intent startMain = new Intent(Intent.ACTION_MAIN);
    startMain.addCategory(Intent.CATEGORY_HOME);
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(startMain);
 }
© www.soinside.com 2019 - 2024. All rights reserved.