通知からアプリを起動すると、アプリの 1 つで問題が発生します。「最近のアプリ」リストには表示されません。
通知がなければ、すべてが期待どおりに機能します。アプリを起動してナビゲートし、終了すると(ホームボタンまたは戻るボタンで)、ホームボタンを長押しして戻ることができます=> OK。
問題は、通知を受け取ったときに始まります。通知からアプリを起動すると、正しい画面が起動し、アプリを使用できます => OK。しかし、アプリを(ホームまたは戻るボタンで)終了すると、「最近のアプリ」リストに表示されなくなります。より正確に:
- 通知からアプリを起動する前にアプリが「最近のアプリ」リストに存在していた場合は、それを削除します
- アプリが「最近のアプリ」リストに存在しない場合、追加されません
以下、ステータスバーに通知を追加する元のコード:
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>
通知から開始された後、アプリを「最近のアプリ」リストに保持する方法を知っている人はいますか?