2014-09-25 50 views
0

我有過意向額外獲得一個字符串的活動:意圖不會重置額外

i.putExtra("static_image", theUri.toString()); 
startActivity(i); 

在我的活動:

Uri imageUri = Uri.parse(intent.getStringExtra("static_image"); 

它的工作原理,但如果我不關閉應用程序,我用一個不同的uri再次打開該活動,意圖給我舊的...

我認爲意圖被重用。我如何重置活動或強制活動使用新的意圖?

感謝

回答

-1

怎麼樣,如果你的意圖刪除它,馬上你找回後?

// test if it exists?  
Uri imageUri = Uri.parse(intent.getStringExtra("static_image"); 

// ...... 
// remove it since you already have it in your variable 
getIntent().removeExtra("static_image"); 
+0

謝謝,但這不會工作......我沒有額外的下一個開始:P – 2014-09-25 21:06:15

1

好的,這解決了我的問題。 在接收器活動覆蓋:

protected void onNewIntent(Intent intent) { 
    super.onNewIntent(intent); 
    this.setIntent(intent); 
}