当我从通知中启动应用程序时,我的某个应用程序出现问题。它从不出现在“最近的应用”列表中。从通知中启动应用程序将其从最近的应用程序历史中删除
没有通知,每件事情都按预期工作:我启动应用程序,导航到当我退出它(带有主页按钮或返回按钮)之后,我可以通过长按Home键重新进入它=>好。
当我收到通知时,问题就开始了。如果我从通知中启动应用程序,它会启动正确的屏幕,我可以使用应用程序=>确定。但是,当我退出应用程序(使用家庭或后退按钮)时,它不会再出现在“最近的应用程序”列表中。更确切地说:
- 如果应用程序存在于从通知启动应用程序之前,“最近的应用程序”列表中,它会删除它
- 如果应用程序是不存在的“最近的应用程序”列表中,它不添加它
下面,我原来的代码中添加通知状态栏:
mNotification = new Notification(R.drawable.ic_notif, message, System.currentTimeMillis());
mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
Intent notificationIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(link));
notificationIntent.putExtra(...);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
mNotification.setLatestEventInfo(context, context.getString(R.string.app_name), message, contentIntent);
notificationManager.notify(ConfigApp.NOTIFICATION_ID, mNotification);
我尝试添加一个FLAG_ACTIVITY_NEW_TASK但它并没有帮助:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW,Uri.parse(link));
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.putExtra(...);
被通知开始活动的舱单申报:
<activity
android:name=".activity.ActivityMessages"
android:label=""
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="hostapp"
android:pathPrefix="/prefixapp"
android:scheme="schemeapp" />
</intent-filter>
</activity>
有谁知道如何保持应用程序中的“最近的应用程序”列表正在启动形成的通知后?
什么Android版本出现这种情况呢? –
如果删除' ',会发生什么?另外,请尝试删除entier'intent-filter'组。 –
Eric
@ WebnetMobile.com每个版本自2.2 –