In my activity, there is a lot of processing done in oncreate() like opening a database, writing files on the sd card. But all of this heavy processing happens only once when the activity is launched the first time and not after that. I am using an Async task to achieve this.
I am using the following code to prevent activity restart during device configuration change.
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
I wish to disable activity restart due to change in device orientation only once when the initial setup takes place and after that, I want to enable activity restart. Any idea how I can achieve this?
add this to your activity tag in manifest file
android:configChanges="orientation|keyboardHidden"