Android - Clear task flag not working for PendingIntent

后端 未结 9 1966
夕颜
夕颜 2020-12-17 09:34

I have a task stack of A > B > C. I am currently on C, and then I press the home button. I get a notification with the intent to take me to Activity A. I press the notificat

9条回答
  •  青春惊慌失措
    2020-12-17 10:05

    Try using the Intent flag FLAG_ACTIVITY_CLEAR_TOP instead of clearing the task. From the Intent documentation:

    If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

    For example, consider a task consisting of the activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then C and D will be finished and B receive the given Intent, resulting in the stack now being: A, B.

提交回复
热议问题