1
votes

Is there a way to set Android Portrait mode on an application level like how we do in iOS as shown below ?

Configure portrait mode in iOS

I do not want to add

android:configChanges="orientation" android:screenOrientation="portrait"

on each Activity entry of the manifest or add the following code

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

in each activity! Thanks in advance..

2

2 Answers

0
votes

You can't do this the same way you do it in iOS. The closest you can come to avoiding boilerplate code in each activity, is to create an Activity, let's say PortraitActivity, where you set orientation:

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

in onCreate and make all your activities extend this activity.

0
votes

configChanges is unnecessary for requesting portrait orientation, but you have to add screenOrientation="portrait" at every activity on manifest or "portraitSensor" that will give both portrait and portraitInverse.