2014-10-05 84 views
0

我有一個顯示通知的應用程序。 該應用程序也有不同的屏幕,片段,標籤,子菜單.... 如果用戶點擊通知應用程序打開,這是我想要的。如果用戶導航到其中一個屏幕或菜單並單擊Home,則會出現問題。該應用程序被最小化,但它不在主要的片段。所以,如果用戶點擊通知,那麼應用程序將打開它的位置。我需要的是從零開始,我的意思是,從Main片段開始。 我使用此選項創建通知:單擊通知時從頭開始重新啓動Android應用程序

Intent intent = new Intent(this, MyMainClass.class); 
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); 

任何想法?

回答

0

試試這個,

Intent notificationIntent = new Intent(context, MainActivity.class); 
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP 
     | Intent.FLAG_ACTIVITY_SINGLE_TOP 
     | Intent.FLAG_ACTIVITY_NEW_TASK); 

PendingIntent pIntent = PendingIntent.getActivity(
     this.getApplicationContext(), 0, notificationIntent, 
     PendingIntent.FLAG_UPDATE_CURRENT); 
+0

對不起,相同的結果。該應用程序未被恢復 – Ton 2014-10-07 17:41:31

相關問題