简体   繁体   English

在Android中将任务恢复到最后状态

[英]restoring the task to it's last state in android

I'm not talking about restoring application state (using Bundle or configuration change or even SharedPreferences) i'm talking about the fact that i have a certain task, that is a base activity: HomeScreenActivity and from there i can have a series of activities opened for the user's flow. 我不是在谈论恢复应用程序状态(使用Bundle或配置更改,甚至是SharedPreferences),而是在谈论我有一项特定任务,即一项基本活动:HomeScreenActivity,从那里我可以进行一系列活动为用户流程打开。 I want in case of application's death or user killed his own session to restore the whole task, not just one activity, i mean to restore the whole activity stack i had before the application was killed. 我想在应用程序死机或用户杀死自己的会话的情况下恢复整个任务,而不仅仅是一个活动,我的意思是恢复应用程序被杀死之前的整个活动堆栈。 if the user was in my billing screen and left off my app i want to take him back to that screen, but i want that if he'll press back he'll go back to my search screen or filtering screen, whatever was there before he left off. 如果用户在我的结算屏幕上并退出了我的应用程序,我想带他回到该屏幕,但是我希望如果他按回去,他将回到我的搜索屏幕或过滤屏幕,无论之前有没有他离开了。

I have no problem saving the activity's order in sharedPreferences and know the order once i start my home screen, but i wonder if there's a way to tel landroid to start an activity, which sould only enter the task's stack and not call the activity's onCreate method unless i actually get to it(with back key). 我将活动的顺序保存在sharedPreferences中并没有问题,并且在启动主屏幕后就知道顺序了,但是我想知道是否有一种方法可以通过tel landroid启动活动,该方法只能输入任务的堆栈而不会调用活动的onCreate方法除非我真的去(用后退键)。

Perhaps someone will have a better idea, but the only thing that comes immediately to mind is to add a "resetup" flag so that you could sort of replay a script of the user's previous activity navigation actions within your app, having your activities start each other up in turn but due to the resetup flag bypassing most of their code so they don't really do anything except essential setup and start the next one. 也许有人会有一个更好的主意,但是立即想到的唯一事情就是添加一个“ resetup”标志,以便您可以在应用程序中重播用户先前的活动导航操作的脚本,让您的活动开始每个其他依次启动,但由于resetup标志绕过了他们的大多数代码,因此除了必要的设置和启动下一个代码之外,他们实际上不执行任何操作。

One complication is that it's probably the activity they were actually in which android will resume. 一种复杂的情况是,这可能是他们实际上将在其中恢复android的活动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM