Activity設置singleTask無法通過Intent獲取值的問題

在項目的頁面跳轉中,Activity啓動順序爲:A—>B—->C——>A

其中A啓動模式設置爲android:launchMode=”singleTask” ,

當C跳轉到A時,A將不再執行onCreate方法,而是直接執行onResume;

C通過intent傳遞參數給A,通過以下方式將無法獲取。

[html] view plaincopy在CODE上查看代碼片派生到我的代碼片

@Override  
protected void onResume() {  
    super.onResume();  
    Bundle bundle = getIntent().getExtras();  
    if (null != bundle) {  
        trande_Amount = bundle.getString("Amount");  
    }  
}  

解決方法:

[html] view plaincopy在CODE上查看代碼片派生到我的代碼片

protected void onNewIntent(Intent intent) {  
       super.onNewIntent(intent);  
       // must store the new intent unless getIntent() will return the old one  
       setIntent(intent);  
   }  

原文鏈接:http://blog.csdn.net/lvxiangan/article/details/43084633

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章