androidandroid-studio-3.6

ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE turns red after upgrading to android studio 3.6.1


I'm just upgrading my android studio to 3.6.1 but I've got a new warning about the orientation which is a new issue for me. The IDE suggested me to set my orientation to SCREEN_ORIENTATION_UNSPECIFIED but I don't know if the suggested orientation is the right way I needed. Does anybody know how to rid of this red underline?

enter image description here


Solution

  • This is a lint warning, not an error, and you can ignore the warning if you don't want to follow the advice.

    To suppress the lint warning in java code, you can add

    //noinspection AndroidLintSourceLockedOrientationActivity
    

    on the line just above the warning.

    In kotlin (works also in java) have to add

    @SuppressLint("SourceLockedOrientationActivity")
    

    annotation e.g. on the method level. Personally I prefer to make the suppression scopes to be as narrow as possible.