I specified in the manifest.xml
the following tag
<activity android:screenOrientation="fullsensors
android:configChanges="orientation|keyboardhidden|keyboard"
</activity>
And android:configChanges="Orientation|keyboardhidden|keyboard"
means avoid recreation of the App in case of "orientation" OR "keyboard is hidden/visible"
And in my App class, I am calling all the activity's life cycle callbacks. And I expected when I rotate/re-orient the device that, no recreation of the App will be occured. Or in other words, the following callbacks, in order, will not be called because of android:configChanges
. The callbacks are onPause()
onStop()
onDestroy()
onCreate()
onStart()
onResume()
and for every time I rotate the device, the App gets recreated and the previously mentioned life cycle's callbacks are called.
Any explanation why that happens?
Here you have not included screenSize
in android:configChanges
.
According to doc
Caution: Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must decalare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
So if you want to receive onConfigurationChanged
callback .. you have to add screenSize
in android:configChanges
.