我想在我的应用程序处于后台时从服务或广播中打开我的 Activity 。
我试过下面的代码
Intent intent = new Intent("android.intent.action.MAIN");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
它在以下 Android 26 API 上运行良好。但对于 26Api 以上,它不启动 Activity 。
它在 android LogCat 中提供流动信息
Timeline: Timeline: Activity_launch_request
最佳答案
Android 10 增加了“从后台启动新 Activity ”的限制。查看文档:Restrictions on starting activities from the background
有关施加这些限制的原因的更多详细信息,请查看 Chet Haase 的主题演讲。 GFM2019-Keynote-Chet Haase
关于java - 如何从 26 API 以上的后台应用程序启动 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59679471/