2014-10-05 88 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

相关问题