Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable only portrait and reverse portrait in phones, "sensorPortrait" not working on phones?

I cant figure out why setting "sensorPortrait" attribute in manifest for an activity doesn't work to allow the activity to go into reverse portrait. This is how I set in manifest

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

The above code is not working for me to get both reversePortrait and portrait on Moto E(4.4.4) or Galaxy S3(4.3), but I can confirm it works on a Nexus 7(5.0.1) tablet, I tried several other answers but this one seems to be the easiest and it is seemingly not working for me on 'phones', am I missing some information that is relevant for getting this to work?

I tried the following link which is just as similar as my question but nothing seems helpful regarding this

Activity in portrait or reverse portrait only

Currently with the flag "sensorPortrait" it behaves just like setting "portrait", in phones.

like image 421
king_below_my_lord Avatar asked Mar 16 '15 14:03

king_below_my_lord


People also ask

How do you reverse portrait on Android?

Like in the 70e Android, by default, the screen will automatically rotate. Setting to enable or disable this feature is under 'Launcher' > 'Settings' > 'Display' > 'Auto-Rotate screen'.

What is reverse portrait mode?

Reverse-portrait is defined to be a rotation of the print-stream page to be imaged by 180 degrees with respect to the medium from the portrait orientation.


1 Answers

If you look at the PhoneWindowManager source code, you can see that it checks for the internal value config_allowAllRotations and uses that to determine if the 180 degree rotation (i.e., reverse portrait on phones) is allowed.

With a default value to false, this means that reverse portrait is disabled on phones. You'll note that the sw600dp value (i.e., tablets) is true, hence why you can use all rotations including reverse portrait on tablet devices.

like image 92
ianhanniballake Avatar answered Sep 28 '22 07:09

ianhanniballake