I'm working on the android live wallpaper applications and need to correctly handle screen orientation changes.
Currently I use onConfigurationChanged
for this purpose(in this method I need to change coordinates of my LWP screen elements. I use andengine
). Everything works fine on the emulators and my test phones, but some my customers with Samsung Galaxy Note2 (t03g), LG thrill(LGE LG-P925) reports the issues with incorrect application work during the screen orientations change.
I don't have these phones on hand, but can suppose that the issue is related to onConfigurationChanged
not being called.
Is it correct to use onConfigurationChanged
method ? Maybe I need to use onSurfaceChanges
or something like that ? Could you please suggest me the correct way to solve this issue ?
Alos, I have added android:configChanges="keyboardHidden|orientation"
into my AndroidManifest.xml
:
<activity
android:name=".WallpaperSettings"
android:configChanges="keyboardHidden|orientation"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity>
In my live wallpaper, which handles orientation changes, I use the onConfigurationChange()
method to check for orientation changes, but I don't have any direct experience with the 2 phones, though I've never gotten any complaints about them. My method looks something along the lines of:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
rotated = true;
}
else {
rotated = false;
}
}
And in the draw()
method, I check the rotated
boolean. There's additional checks in the onSurfaceChanged()
to correct for resolution changes when the orientation changes.
I don't have android:configChanges="keyboardHidden|orientation"
in my manifest file at all.
android:configChanges="orientation|screenSize"
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).
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