简体   繁体   English

将应用程序置于与最近活动中按应用程序相同的前台?

[英]Bring application to foreground same as Pressing the application in the recent activity?

与用户在“ 最近活动”活动中按应用程序图标/图像时一样,我该如何使应用程序回到前台。

You just do what Android does when the user presses the application icon/image: 您只需执行用户按下应用程序图标/图像时Android的操作即可:

Intent intent = new Intent(context, MyRootActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

Make sure that you specify the root activity of your application (ie: the one with ACTION=MAIN and CATEGORY=LAUNCHER). 确保指定应用程序的根活动(即:具有ACTION = MAIN和CATEGORY = LAUNCHER的活动)。

Do you need to bring back your app based on some global keyevents? 您是否需要根据一些全局关键事件来恢复您的应用程序?

Couple of things that came in my mind.. You can to write a view and listen to the global touch. 我脑海中浮现出几件事。您可以编写视图并聆听全球触动。 Something like this thats stated in example 这样的例子示例中说明了

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

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