tags:

views:

84

answers:

2

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 ?

+1  A: 

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 http://developer.android.com/intl/zh-TW/guide/topics/fundamentals.html#actlife for understanding activity life cycle.

Konstantin Burov
A: 

i really dont know how to use this... on the developer guide it says to use the code

@Override public Object onRetainNonConfigurationInstance() { final MyDataObject data = collectMyLoadedData(); return data; }

but on eclipse it says collectMyLoadedData(); is not an defined method

but i dont know what to define in it ? :/

i did change the MyDataObject to "fill" which is the name of my class