Disable Screen Orientation Dynamically In Android(Java)

246 views Asked by At

I want to lock my application to portrait mode for all the activities. I know this can be done by setting android:screenOrientation="landscape" in activity tag in manifest. but I have lots of activities, so I was wondering is there any way to do it on application level either by some xml tag in manifest or in code anyhow, so I wont have to define it in all the activity tags.

1

There are 1 answers

0
Triode On BEST ANSWER
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

Or

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Use this method in the BaseActivity. And extend this activity for every other activity in your application.