User7723337
User7723337

Reputation: 12018

Android 'onConfigurationChanged' event not getting fired

Is it that when we call setRequestedOrientation from then function onConfigurationChanged then after onConfigurationChanged never gets called?

As i have read somewhere that when we call setRequestedOrientation function from the activity then function onConfigurationChanged never gets called.

I am in dead block now, no way to go.

I have my activity which i need to display in portrait mode only, but when user plays the video in the video view and then after when user changes the orientation to landscape then i need to make the activity+video in the landscape.

Problem is that when i call setRequestedOrientation method to set the application orientation to portrait then after method onConfigurationChanged never gets called.

And when i remove the call setRequestedOrientation then when video is not running my and when user changes the orientation then my activity also changes the orientation which i can't control.

Upvotes: 0

Views: 1537

Answers (2)

Marcelo Idemax
Marcelo Idemax

Reputation: 2810

Do it to get device orientation by sensor again.

setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_SENSOR );

Upvotes: 1

Scott Helme
Scott Helme

Reputation: 4799

The setRequestedOrientation call is to force your activity to remain in the given orientation, so you can lock it to portrait for example. This is why onConfigurationChanged doesn't get called.

If you want to rotate the app then you can specify different layout XML files for each orientation or get the orientation of the app and deal with it programatically.

See here: http://developer.android.com/reference/android/app/Activity.html#setRequestedOrientation(int)

And here: http://developer.android.com/reference/android/content/res/Configuration.html#orientation

Upvotes: 0

Related Questions