Android Studio のバージョンを3.6にUpdateして、プロジェクトをOpenすると、
Manifest.xnlで警告が出ていました。
今後の為に、対策方法を残しておきたいと思います。
警告文言:
「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.」
原因
AndroidManifest.xmlでactivityのOrientationを縦または横固定にしているため。
(Android studio 3.6で警告が出るようになりました)
レイアウトの向きを縦または横固定にすることで、ユーザエクスペリエンスが損なわれるために警告が出ているようです。
そうは言っても、向きを固定で実装したい場合もあるので、以下対策を記載しておきます。
対策①
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" (★) package="hogehoge"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AppCompat.Light.NoActionBar"> <activity android:name=".MainActivity" android:screenOrientation="landscape" tools:ignore="LockedOrientationActivity"> (★) <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
「tools:ignore=”LockedOrientationActivity”」を記述して警告を消す。※上記(★)
画面の向きを固定にしたい場合は、この方法で警告を消すことができます。
対策②
変更前: android:screenOrientation="landscape" 変更後: android:screenOrientation="unspecified"
screenOrientation の指定を、unspecifiedまたはfullSensorに変更する。
※この変更を行うことでアプリの向きは固定化されないので注意必要です。
unspecifiedとfullSensorの違いは以下の通り。
※詳細はdevelopersサイトを参照下さい。
■unspecified
デフォルト値。システムが画面の向きを選択します。システムが使用するポリシー、つまり特定の状況における選択は、端末により異なる場合があります。
■fullSensor
画面の向きは、端末の方向センサーによって決まり、4 つの画面の向きすべてを使用できます。これは “sensor” と似ていますが、端末の通常の動作にかかわらず、4 つの画面の向きすべてを使用できる点が異なります(たとえば、一部の端末では通常、反対の縦向きや反対の横向きは使用しませんが、それらの向きも有効になります)。API レベル 9 で追加。
以上。