user434885
user434885

Reputation: 2018

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 screen changes orintation ? is there a solution to this problem ?

Upvotes: 2

Views: 1376

Answers (1)

Konstantin Burov
Konstantin Burov

Reputation: 69228

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.

Upvotes: 2

Related Questions