簡體   English   中英

如何銷毀 android 中的最后兩個先前訪問的活動

[英]how to destroy last two previous visited activity in android

For example I have four activity A, B, C, and D. I go from A to B and from B to C and then from C to D. Now in Activity D, on particular button click, I want to destroy Activity D as以及活動 C 並想跳到活動 B。現在,當我單擊活動 B 中的后退按鈕時,它應該在活動 A 上導航我。請幫助某人如何實現此功能。 注意:我不想在從活動 C 導航到活動 D 時破壞活動 C

D中,當您想要導航回B時,請執行以下操作:

Intent intent = new Intent(this. ActivityB.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);

這將導致 A 和 D 從堆棧中刪除,B 現在將顯示在您離開時它所在的 state 中,並且onNewIntent()將在B上調用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM