2013-05-15 101 views
0

在我的應用程序中,我使用Notification。當用戶點擊此通知時,比啓動我的應用程序(如果它未運行)或對話框顯示。 在活動中我也檢查使用意圖Android開始活動

intent = getIntent(); 
    if (intent.getExtras() != null) { 
     mPrice = getIntent().getExtras().getString("price"); 
     showDialog(mPrice); 
    } 

一切工作好,除非我的活動通過通知開始,當我從應用程序退出使用返回按鈕和啓動應用程序每次它再次表明我對話。我曾嘗試使用getIntent().getExtras().remove("price")刪除此附加功能,但它不起作用。如何解決這個問題,如果點擊通知,該對話框只顯示一次?

+0

可能重複[刪除額外的傳入意圖(http://stackoverflow.com/questions/4520961/removing-extras-from-passed-in-intent ) – Kuffs

回答

-1

檢查getString實際上已經返回的值,如:

intent = getIntent(); 
if (intent.getExtras() != null) { 
    mPrice = getIntent().getExtras().getString("price"); 
    if (mPrice != null) showDialog(mPrice); 
} 
0

getExtras創建額外的副本。

您需要使用的

getIntent().removeExtra("price"); 
+0

它沒有幫助。對話框再次出現。 –