| Issue 13: | Switching orientation resets the app | |
| 1 person starred this issue and may be notified of changes. | Back to list |
onCreate() is called when orientation is switched. In order to fix check this page: http://stackoverflow.com/questions/584779/android-switching-between-landscape-and-portrait-mode-makes-intent-lose-values
Jun 27, 2009
(No comment was entered for this change.)
Status:
Fixed
|
Maybe we should save state via preferences during an orientation switch: public class CalendarActivity extends Activity { ... static final int DAY_VIEW_MODE = 0; static final int WEEK_VIEW_MODE = 1; private SharedPreferences mPrefs; private int mCurViewMode; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences mPrefs = getSharedPreferences(); mCurViewMode = mPrefs.getInt("view_mode" DAY_VIEW_MODE); } protected void onPause() { super.onPause(); SharedPreferences.Editor ed = mPrefs.edit(); ed.putInt("view_mode", mCurViewMode); ed.commit(); } }