Can you please explain onCreate and Bundles?

醉酒当歌 提交于 2019-12-04 23:27:18

问题


I have been looking it up and I just cant seem to wrap myself around the onCreate and Bundles. I understand that the onCreate is called when the program starts but its how the Bundles get passed around and how they are pertinent. Can anyone try to put this into plain english because I cant seem to find it well described.

Thanks


回答1:


The Bundle in the onCreate method should hold the state of you activity before it was killed.

Simple example, when you change the orientation of your device your activity is recreated. Imagine the user is filling a long form and he/she accidentally changes the orientation. When the app gets restarted all data entered will be lost unless you persist that information. One possibility is using a Bundle.

If you want to know how to use it, I would recommend that you read this question.



来源:https://stackoverflow.com/questions/2887368/can-you-please-explain-oncreate-and-bundles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!