在android中终止向导的最佳方法
我在android中有一个预订向导,当我说向导时,我的意思是我有多个活动(意思是屏幕),这些活动从一个活动传递到另一个活动,直到预订完成。在每一步中,我的信息可能无效,因此我必须回溯 2-3 个活动并重新开始,我回溯的所有活动都应该被销毁,他们可能需要使他们填充的单例数据容器无效他们的数据。 我想到了两种方法来做到这一点:
- 使用
startActivityForResult()
启动与向导相关的所有活动,以便在活动完成时收到通知以及错误代码(完成正常或发生错误)并采取行动相应地(例如:如果中间一个活动失败,它将返回失败,前一个活动也将返回失败,直到我到达向导的第一个活动,在该活动中我要么用对话框声明错误,要么显示“谢谢”屏幕。) - 我可以发送对具有某些参数的意图的反应,这样我就有一个“关闭和干净”的意图消息来关闭之前的活动等...
哪种方法更好,还有其他有趣\有效的方法来做到这一点?
I have a reservation wizard in android, when i say wizard i mean i have multiple activities (meaning screens) that are passed from one to another until booking is complete. in each step of the way my info may be invalid and so ill have to back track 2-3 activities and start all over, all the activities i back tracked should be destroyed, they may need to invalidate a singleton data container that they filled with their data.
I thought of 2 ways to do this:
- start all activities related to the wizard with
startActivityForResult()
so i get notification when an activity is finished and with which error code (finished OK or error occurred) and act accordingly (for instance: if in the middle an activity fails it will return failed and the previous one will return failed as well until i get to the wizard's first activity where i either declare the error with a dialog or show the 'thank you' screen.) - I can send an react on intents with certain parameters so i have a 'close and clean' intent message that close down the previous activity etc...
which way is better, any other interesting\efficient way to do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了一个提示,让我朝不同的方向思考:
我想玩的活动
他们在栈里面的位置
一个 ActivityGroup 对象,它保留
所有活动都处于活动状态(如选项卡中)
并在堆栈上,但你可以控制
显示哪一个以及哪一个是
不是。活动组将包含
状态机逻辑有关
哪个 Activity 不应该
显示并且应该是
处置。
I Got a hint that got me thinking in a different direction:
the activities i want to play with
their pposition on the stack inside
an ActivityGroup Object which keeps
all activities alive (like in Tab)
and on the stack, but you control
which one is displayed and which is
not. the activity group will contain
the state machine logic regarding
which Actvity should not be
displayed and which should be
disposed.