我有幾個活動說A,B,C。活動A開始B,B開始C等等。在我的應用程序中,我放置了一個導航抽屜,允許用戶返回到活動A.當用戶返回到活動A時,我已經傳遞了一些標誌,這些標誌實際上並未重新啓動活動,但只是恢復活動。通過在包中傳遞新數據來恢復舊活動
intent = new Intent(activity, A.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);
現在我試圖通過捆綁傳遞一些數據。
bundle.putInt("selectedTab", FEATURED_COUPONS);
intent.putExtras(bundle);
但是在我的活動中,包總是空的。
if(bundle != null)
{
if(bundle.containsKey("selectedTab"))
{
int tab = bundle.getInt("selectedTab");
}
}
發佈代碼,獲取捆綁包並開始活動A –