Expecting 'android:screenOrientation=“unspecified”' or '“fullSensor”' for this activity

…衆ロ難τιáo~ 提交于 2020-04-12 07:43:09

问题


I upgraded my Android Studio to 3.6.0. Now, I get the following error in my Manifest.xml file.

Expecting 'android:screenOrientation="unspecified"' or '"fullSensor"' for this activity so the user can use the application in any orientation and provide a great experience on Chrome OS devices.

Should I convert it to "fullSensor"? How can I get rid of this problem?

Orientation of my activities is portrait. I want to keep using portrait orientation in my activities.


回答1:


This is a kind of warning to inform developers that for big screen devices it is not good to restrict the orientation. However if your application only supports portrait mode then this warning can be disabled by doing the following.

Mac: Android Studio -> Preferences

Windows: File -> Settings

Then:

  1. Search for "chrome"
  2. Uncheck "Activity is locked to an orientation"
  3. Apply and ok.

Unchecking step screen shot




回答2:


Given your application only supports portrait mode, you can ignore these errors by adding tools:ignore="LockedOrientationActivity" to all of your activities or just to the top level <manifest> tag which will apply to all activities.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="LockedOrientationActivity"
    ...
    ...



回答3:


If you use portrait orientation just so you don't have to use Bundle to store data, please learn how to use Bundle. It is a hacky way of not having to use Bundle, but believe me this doesn't solve all your problems. Sorry if i am wrong, but i thought that by setting screen orientation is a great workaround. It just brings more problems in long run




回答4:


Add this to the manifest tag:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="LockedOrientationActivity"
...


来源:https://stackoverflow.com/questions/60396601/expecting-androidscreenorientation-unspecified-or-fullsensor-for-this-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!