请提供活动导航建议
好的 。 。 。我已经阅读了数小时的建议、论坛和开发人员页面,但没有得出结论性的答案。
我所拥有的:是一个包含 8 个活动的应用程序,每个活动都有一组略有不同的按钮来导航到其他一些活动。每个活动都有多种形式的数据收集,最终以收集所有应用程序 UI 数据的电子邮件意图结束。
问题:我似乎无法找到与 onSavedInstanceState 结合使用导航按钮的正确方法,因此无论如何,每次启动活动时,它都会显示用户到目前为止输入的任何和所有数据(sp?)该应用程序的实例。除了关闭应用程序之外,我不想保存数据。我确实希望用户能够在活动中根据需要来回导航,而不会丢失数据,直到应用程序关闭。
这就是我所拥有的:
活动 A:具有用于:活动 B、C、D、E 和 F(F=电子邮件意图)的按钮
活动 B:具有用于:活动 G 和 A 的按钮 活动 G:具有用于:活动 B 和 A 的按钮
活动 C:具有用于:活动 H、I 和 A 的按钮 活动 H:具有用于执行以下操作的按钮:活动 C、I 和 A 活动 I:具有用于:活动 H、I 和 A 的按钮
活动 D:具有用于:活动 A 的按钮
活动 E:具有用于:活动 A 的按钮
有更好的方法来设置导航吗? (这对于我相当确定的上下文来说是最佳的)
正确的启动模式/标志/保存实例状态是什么以及达到正确结果的什么?我可以根据需要详细解释。
我知道我需要保存数据,问题是设置活动,以便我在每个活动中放入的导航按钮始终打开显示所有以前保存的数据的活动(在当前任务实例中)
我将所有活动设置为启动模式: singleTask,我没有手动编码任何标志,并且我已经正确设置了 onsaveinstance,但事情很简单: Activity B->活动A->活动 B(仅使用我的按钮)活动 B 在转到 A 并再次返回后没有保存任何内容(我再次没有使用后退键,我在布局中使用导航按钮)我该如何解决这个问题?
奇怪的是,活动 A 确实保留了内存,但其他活动都没有保留内存
Ok . . . I have read hours upon hours of advice and forums and developer pages to no conclusive answer.
what I have: is an app with 8 activities and each has a slightly different set of buttons to navigate to some of the other activities. Each activity has multiple forms of data collection, ultimately ending in an e-mail intent which collects all application UI data.
Problem: I cant seem to find the proper way to use the navigation buttons in conjuction with onSavedInstanceState so that no matter what, everytime an activity is started it will appear with any and all data the user has inputed(sp?) thus far, during this instance of the application. I dont want to save data beyond closing the app. I do want the user to be able to navigate back and forth as much as necessary within the activities without losing data until the app closes.
This is what I have:
Activity A: has buttons to: Activity B, C, D, E, and F(F=email intent)
Activity B: has buttons to: Activity G, and A
Activity G: has buttons to: Activity B, and A
Activity C: has buttons to: Activity H, I, and A
Activity H: has buttons to: Activity C, I, and A
Activity I: has buttons to: Activity H, I, and A
Activity D: has button to: Activity A
Activity E: has button to: Activity A
Is there a better way to set up my navigation? (this is optimal for the context I am fairly sure)
And what is the proper launch mode/Flags/savedinstancestate and whatever to achieve proper result? I can explain elaborate as much as needed.
I am aware I need to save the data the problem is setting up the activities so that the navigation buttons i have put in each activity always open activity showing all previously saved data (in the current task instance)
I have all activites set to launchMode:singleTask, I have not manually coded any flagsand I have set up onsavedinstance properly but something as simple as: Activity B-> Activity A-> Activity B (using only my buttons) Activity B saves nothing after going to A and back again (again I am not using back key, I am using my navigation buttons in the layout) How can I fix this??
Oddly tho Activity A DOES retain memory but none of the other activities do
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么使用 singleTask?
你不是在找吗
?
Why you're using singleTask?
Aren't you looking for
?