4

I want to block my application orientation to portrait, but still receive orientation changes events. So I've tried to add the android:screenOrientation="portrait" attribute for blocking the orientation and the android:configChanges="keyboardHidden|orientation" attribute for receiving the orientation changes events in the ovverriden method onConfigurationChanged. Still the method doesn't get called. Is there a way to achieve this?

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Gratzi
  • 4,633
  • 12
  • 42
  • 58

3 Answers3

1

By forcing the orientation of your activity to portrait mode, you're not able to receive orientation changes.

Balaji Khadake
  • 3,449
  • 4
  • 24
  • 38
  • So there's no way you could specify a certain orientation and receive the notifications? – Gratzi Jul 27 '11 at 12:43
  • According to my knowledge it's not possible. Check this one post over here. http://stackoverflow.com/questions/5620033/onconfigurationchanged-not-getting-called – Balaji Khadake Jul 27 '11 at 12:56
  • I've read it and some say that it should work. But for me it doesn'r. Anyway, I think don't understand why bloking the orientation should block the notifications. Those are separate functions. It has no logic. – Gratzi Jul 27 '11 at 13:02
  • Am also not getting this one. But, I had faced same problem. – Balaji Khadake Jul 27 '11 at 13:34
1

Check Manifest.xml file. It should be like as below:

    <activity android:name="YourActivity1"
        android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation|keyboardHidden"></activity>
    <activity android:name="YourActivity2"
        android:screenOrientation="portrait" android:windowSoftInputMode="adjustPan"
        android:configChanges="orientation|keyboardHidden"></activity>

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
Subrat
  • 3,928
  • 6
  • 39
  • 48
-1

are you sure you write this for main activity like < activity android:screenOrientation="portrait"...

GauravSTomar
  • 604
  • 1
  • 7
  • 26