How can I save the application back stack to a bundle?

一世执手 提交于 2019-12-03 14:27:38

As far as I know Android system won't let you get the task's back stack, it can only give you the top Activity of all tasks running. Hence, you will need to implement your own mechanism of maintaining the Activities back stack. Implementation of LocalActivityManager might help you, particularly, its saveInstanceState() method. So you may do something similar and call onSaveInstanceState(Bundle) of Activities in your back stack whenever you want and then persist Bundle (in a file, for example). If you use Fragments then you will also need to maintain their back stack.

Perhaps, android:alwaysRetainTaskState might help you to solve your problem not diving into managing back stack.

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