开发者

Android dev: screen orientation problems

ok i am having real troubles with screen orientation. My application has a countdown timer in it along with other variables. And everytime the screen goes from landscape to portrait mode all my variables get reset to their default value, and the countdown timer gets canceld and reset !!! Is the onCreate method called everytime the sc开发者_Python百科reen changes orintation ? is there a solution to this problem ?


Yes, onCreate is called every time you rotate the screen. You have to save state of your app by overriding onSaveInstanceState method and the restore the state at onCreate. At both methods you have Bundle object to store/retrieve state.

Read https://developer.android.com/guide/components/fundamentals.html#actlife for understanding activity life cycle.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜