Android 正在从PendingEvent上的堆栈中删除启动器活动

Android 正在从PendingEvent上的堆栈中删除启动器活动,android,android-pendingintent,Android,Android Pendingintent,我有些问题。当我的应用程序不在后台(从最近删除)时,一切正常。但是,当我的应用程序处于最新状态,然后我通过通知挂起意图打开“ResponseActivity”时,在返回时单击“ResponseActivity”,我将进入我的主活动(启动器活动)。 我已经添加了FLAG\u ACTIVITY\u NEW\u任务,但它似乎没有这样做 Intent intent = new Intent(this, ResponseActivity.class); intent.setFlags(In

我有些问题。当我的应用程序不在后台(从最近删除)时,一切正常。但是,当我的应用程序处于最新状态,然后我通过通知挂起意图打开“ResponseActivity”时,在返回时单击“ResponseActivity”,我将进入我的主活动(启动器活动)。 我已经添加了FLAG\u ACTIVITY\u NEW\u任务,但它似乎没有这样做

    Intent intent = new Intent(this, ResponseActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP   | Intent.FLAG_ACTIVITY_NEW_TASK);

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_launcher_background)
            .addAction(0, "Other", pendingIntent) 
            .setLargeIcon(getCircleBitmap(bitmap))
            .setContentTitle(userDB.getName())
            .setContentText(smallText)
            .setAutoCancel(true)
            .setDefaults(Notification.DEFAULT_ALL)
            .setColor(getResources().getColor(R.color.colorPrimary))
            .setPriority(NotificationCompat.PRIORITY_DEFAULT);


    NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel channel = mNotificationManager.getNotificationChannel(NOTIFICATION_CHANNEL_ID);

        channel.setDescription("");
        channel.enableLights(true);
        channel.setLightColor(Color.RED);
        channel.enableVibration(true);

        mNotificationManager.createNotificationChannel(channel);
    }

    mNotificationManager.notify(1000, mBuilder.build());
舱单:

<application
    android:name=".ApplicationContextProvider"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".SplashActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".MyFirebaseInstanceService"
        android:stopWithTask="false">
        <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
        </intent-filter>
    </service>

    <activity android:name=".MainActivity" />
    <activity android:name=".LoginActivity" />

    <activity android:name="verification.MyVerifyPhoneActivity" />
    <activity android:name=".ResponseActivity"
        android:theme="@style/AppTheme2">

    </activity>
</application>

如果要确保选择通知时堆栈中只有
响应活动
,可以执行以下操作:

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
而不是:

intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);

请在问题中张贴您的清单。