如果我的应用程序是后台应用程序,我将使用这种方法从Service启动活动:
Intent intent = new Intent(this, FromBackgroundActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
它运作完美,
但是如果
FromBackgroundActivity
是活动的,并且我按Home键,它将全部置于后台。而且,如果我在任务栏中单击我的应用程序,它会将我的应用程序还原到前台,但没有
FromBackgroundActivity
,它将被销毁。 (如何使用
FromBackgroundActivity
从后台还原我的应用程序? 最佳答案
尝试intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK));
它将清除所有任务并转到FromBackgroundActivity。