Opening the App from Recents opening the old activity in Android?

喜夏-厌秋 提交于 2020-06-28 03:57:14

问题


I have 4 Activities: Launcher, MainActivity(SingleTask), NotificationActivity, ExampleActivity.

When the user clicks on the notification, NotificationActivity opens then ExampleActivity and finishes the NotificationActivity.

When I press back MainActivity opens. Now if I press back, the application gets closed. If the user then opens the app from the recent Tasks, NotificationActivity opens then ExampleActivivty. But if the user opens the app from the icon, Launcher Activity opens then MainActivity.

How to handle this situation?


回答1:


Exactly this problem is covered in my answer to this question:

Remove data from notification intent

When you select your app from the list of recent tasks, Android remembers how the app was originally launched (in your case, via Notification) and starts the app again the same way. This can be considered a bug or a a feature, depending on what you expect to happen.

I've got a few suggestions in my answer that you can use to deal with it.



来源:https://stackoverflow.com/questions/61965236/opening-the-app-from-recents-opening-the-old-activity-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!