Home > Software engineering >  block or ignore autorotate in android
block or ignore autorotate in android

Time:01-14

is there any possibility to block or ignore autorotate. because I want my application should be fixed to portrait orientation. but when I enable the auto-rotate in mobile, my application can able to rotate portrait and landscape. even I have added the android:screenOrientation="portrait" and tools:ignore="LockedOrientationActivity" in the AndroidManifest file, it still allows rotation of the application.

Can anyone please help to fix my application has portrait orientation even auto-rotate enabled? I have searched on google. but no clue. please suggest to me some idea to fix this issue.

CodePudding user response:

Check if you added this code to Activity, not to whole Application

  <activity
        android:name=".ui.activity.SplashActivity"
        android:exported="true"
        android:configChanges="orientation|keyboardHidden"
        android:screenOrientation="portrait">
        
    </activity>

CodePudding user response:

You cannot stop the activity from rotating when auto-rotate is turned on.

This is because android see's that the user wants to rotate the screen by turning auto-rotate on. If you are still able to stop the app from rotation in auto-rotate,then there is no use of auto-rotate feature given in android.

So , the answer is you cannot stop the app from rotating

  •  Tags:  
  • Related