I have a activity. I have a process and this is very long. I changed the screen orientation (portrait to landscape), they process is start again... I want to disable onCreate() on change screen orientation.
How make I this?
I have a activity. I have a process and this is very long. I changed the screen orientation (portrait to landscape), they process is start again... I want to disable onCreate() on change screen orientation.
How make I this?
Add this to your manifest under <activity>
:
android:configChanges="keyboardHidden|orientation|screenSize"
I just added this on my activity
android:configChanges="keyboardHidden|orientation|screenSize"
Like this
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/myBoards"
android:theme="@style/AppTheme.NoActionBar" />
Am I right assuming that you start an AsyncTask?
Please, read Is AsyncTask really conceptually flawed or am I just missing something?
In general, you should save the Activity state in onSaveInstanceState(Bundle outState) and restore in onCreate(Bundle savedInstanceState).
There are things that cannot be packed into a bundle, for example, an AsyncTask; you may pass such things via onRetainNonConfigurationInstance().
And, of course, there still are static variables and member fields of the Application object.