如果我的应用程序是后台,我正在使用这种方式从服务启动 Activity :
Intent intent = new Intent(this, FromBackgroundActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
它工作完美,
但如果
FromBackgroundActivity
处于 Activity 状态,我按 Home 键将所有内容置于后台。如果我在任务栏中单击我的应用程序,它会将我的应用程序恢复到前台但没有
FromBackgroundActivity
,它被破坏了。 (如何使用
FromBackgroundActivity
从后台恢复我的应用程序?
最佳答案
试试 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
它将清除所有任务并转到 FromBackgroundActivity。
关于android - Intent.FLAG_ACTIVITY_NEW_TASK 的 Activity 已被销毁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19048360/