I realize that there are a couple other posts on this topic, however the solutions for those posts are not working for me.
Basically, I want to cease my Activity from restarting upon a device orientation change. To do this, I have modified the activity in the manifest file:
<activity android:name=".MyActivity" android:configChanges="orientation|keyboardHidden"></activity>
and I have overridden onConfigurationChanged()
in my Activity:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
System.out.println("IN onConfigurationChanged()");
}
However, the activity is still restarting upon an orientation change, and the onConfigurationChanged()
method is not being called.
Does anyone know why this may be happening?
You should use 13 API and set this configuration in your activity's part of the manifest: android:configChanges="orientation|keyboardHidden|screenSize"
It works fine. At all Android version.
Change your manifest to following
<activity android:name=".MyActivity" android:configChanges="orientation|keyboardHidden|screenSize"></activity>
and refer this link for detailed explanation orientation issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With