将任务恢复到 android 中的最后状态

发布于 2024-10-06 17:47:30 字数 393 浏览 3 评论 0原文

我不是在谈论恢复应用程序状态(使用 Bundle 或配置更改甚至 SharedPreferences),而是在谈论我有某个任务的事实,即一个基本活动:HomeScreenActivity,从那里我可以进行一系列活动为用户流量开放。 我希望在应用程序死亡或用户杀死自己的会话的情况下恢复整个任务,而不仅仅是一个活动,我的意思是恢复应用程序被杀死之前的整个活动堆栈。如果用户在我的计费屏幕中并离开了我的应用程序,我想让他返回到该屏幕,但我希望如果他按返回,他将返回到我的搜索屏幕或过滤屏幕,无论之前有什么他不再说话了。

我在sharedPreferences中保存活动的顺序没有问题,并且一旦启动主屏幕就知道顺序,但我想知道是否有一种方法可以告诉landroid启动一个活动,它只能进入任务的堆栈而不调用活动的onCreate方法除非我真的到达它(用后退键)。

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.
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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔纱相望 2024-10-13 17:47:30

也许有人会有更好的主意,但立即想到的唯一一件事就是添加一个“重置”标志,以便您可以在应用程序中重播用户之前的活动导航操作的脚本,让您的活动每次启动其他依次启动,但由于重置标志绕过了大部分代码,因此除了必要的设置并开始下一个之外,它们实际上并没有做任何事情。

一个复杂的情况是,这可能是 Android 将恢复的实际活动。

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.

One complication is that it's probably the activity they were actually in which android will resume.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文