Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top