How to enable only portrait and reverse portrait on phones, does “sensorPortrait” not work on phones?

I can’t understand why setting the sensorPortrait attribute in the manifest for the activity does not work to allow the activity to switch to the reverse portrait. This is how I set the manifest

<activity android:name=".MainActivty" android:label="Testing" android:screenOrientation="sensorPortrait" android:windowSoftInputMode="stateHidden" android:configChanges="orientation"> </activity> 

This code does not work for me to get both a reverse portrait and a portrait on Moto E (4.4.4) or Galaxy S3 (4.3), but I can confirm that it works on a Nexus 7 tablet (5.0.1), I tried a few other answers, but this one is probably the simplest and doesn’t seem to work for me on “phones”, do I have enough information that is relevant for this to work?

I tried the following link, which is just as similar as my question, but nothing seems useful for this

Activity only in portrait or reverse portfolio

Currently, with the "sensorPortrait" flag, it behaves exactly the same as the "portrait" setting on phones.

+5
source share
1 answer

If you look at the source code of PhoneWindowManager , you will see that it checks the internal value of config_allowAllRotations and uses this to determine if it is allowed to rotate 180 degrees (i.e., reverse portrait on phones).

With a default value of false , this means that reverse portrait is disabled on phones. You will notice that the value of sw600dp (i.e., Tablets) is true, so you can use all the turns, including reverse portraiture on tablet devices.

+1
source

Source: https://habr.com/ru/post/1215454/


All Articles