开发者

How to keep track of an activity in order to restart it later

开发者 https://www.devze.com 2023-02-24 09:12 出处:网络
I have an activity that requires a number of actions to be done before it can perform its task. in the onResume() method of that activity a check is done to determine if the requirements are met, if n

I have an activity that requires a number of actions to be done before it can perform its task. in the onResume() method of that activity a check is done to determine if the requirements are met, if not a chain of activities will be activated to complete the requirements. what would be the best approach to keep record of the original activity in order to get back to it after the requirements have been gathered.

My solution was to pass the original activity's intent contents through the activities call chain in order to be able to restart the original 开发者_开发百科activity again once all the requirements are gathered but i feel that this is not the optimal solution.

Thanks


Hope this makes sense, I'm trying to understand your requirements as best I can since you don't actually say what the application does.

I'd have the base activity check the prerequisites, then fire off the first relevant secondary activity with startActivityForResult. I'd have the secondary activity use setResult(RESULT_OK)/finish() which would bring control back to the base activity. I'd have the base activity check the prerequisites anew each time rather than trying to remember what had supposedly been completed. The shared preferences could be used to store when prerequisites were completed by the secondary tasks if necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消