且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从后台以编程方式恢复 Android Activity

更新时间:2023-12-04 16:34:30

为了将您的应用程序带到前台,您必须从另一个上下文(ServiceBroadcastReceiver).仅从 Activity 中调用 startActivity() 不会将您的应用带到前台.

In order to bring your app to the foreground, you must call startActivity() from another context (either a Service or a BroadcastReceiver). Just calling startActivity() from within an Activity won't bring your app to the foreground.

Intent 中不需要 ACTION 和 CATEGORY,但需要设置 Intent.FLAG_ACTIVITY_NEW_TASK.

You don't need the ACTION and CATEGORY in your Intent, but you do need to set Intent.FLAG_ACTIVITY_NEW_TASK.