0

In my manifest file I specified android:configChanges="orientation". And I noticed that when turning off the screen while in landscape the onConfigurationChanged() method is called once with portrait status and then called again with landscape status when waking up the screen.

What is the reason for this ? Is there any way to disable it ?

sdabet
  • 18,360
  • 11
  • 89
  • 158
  • I think this link will help you. [linnk][1] [1]: http://stackoverflow.com/questions/1512045/how-to-disable-orientation-change-in-android – user4232 Jul 10 '12 at 08:49
  • it works as specified. If you don't have android:configChanges="orientation" then default handling of configuration change is done so onConfigurationChanged is not called. If you have this entry then you are declaring that your code will handle this event and onConfigurationChanged is called. – Marek R Jul 10 '12 at 08:56
  • Ok, but I still don't understand why screen goes back to portrait mode when switching off and then back again to landscape mode when waking up – sdabet Jul 10 '12 at 09:00

3 Answers3

0

Use this in your manifest file--

   <android:configChanges="orientation|keyboardHidden" >

This will never let your screen change when you rotate the screen landscape or portrait.

Hulk
  • 2,565
  • 16
  • 24
0

Use this one in your android menifest

android:configChanges="orientation"

for landscap

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

if you want unspecified

 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
kyogs
  • 6,766
  • 1
  • 34
  • 50
0

The problem seems related to the lock screen which forces the layout back to portrait when switching screen off/on.

I solved my issue by ignoring calls to onConfigurationChanged() between the calls to onPause() and onResume()

sdabet
  • 18,360
  • 11
  • 89
  • 158