我有我的活動如下設置:結算活動堆棧不工作
A(noHistory) - 「乙 - 」ç - > d - >電子
所以,當我開始activity E
從activity D
我希望E
成爲根活動並清除後面堆棧的其餘部分。
我也跟着在這裏很多帖子中提到的解決方案,它是下列標誌添加到我的意圖:
final Intent explicitIntent = new Intent(this,
E.class);
explicitIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
explicitIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(explicitIntent);
然而,Activity E
(這是以前沒有運行)不會成爲回堆棧的根。相反,只有Activity D
從後退堆棧中刪除,如果我按下後退按鈕,C
和B
仍然存在。
因此,我想在SDK < 11中實現真正不可能的功能,如下所述:Clear the entire history stack and start a new activity on Android?這些線
explicitIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
explicitIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
:
你想從E回到A嗎? – Rasel 2012-03-30 09:12:41
檢查下面的鏈接,一個類似的問題。它可能會幫助你。 [如何清除Android Stack的活動?](http://stackoverflow.com/questions/4190429/how-to-clear-the-android-stack-of-activities) – 2012-03-30 09:18:33
@Rasel不,我想當我從E – 2012-03-30 09:59:39