Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In AndroidManifest: Expecting android:screenOrientation="unspecified"

Android Studio 3.6.

I want my app to be always in portrait mode. So in my AndroidMainfest.xml:

<activity    android:name=".activity.SplashActivity"    android:screenOrientation="portrait">    <intent-filter>       <action android:name="android.intent.action.MAIN" />        <category android:name="android.intent.category.LAUNCHER" />    </intent-filter> </activity> 

I run the app and SplashActivity shows in portrait mode. Nice. But the editor shows the following error:

Expecting android:screenOrientation="unspecified" 

Why?

like image 768
Alexei Avatar asked Oct 23 '19 08:10

Alexei


People also ask

What is Tools ignore LockedOrientationActivity?

Since as a part of functionality app supports portrait orientation, so added tools:ignore="LockedOrientationActivity" in the manifest to remove the lint warning related to screen orientation.

What is fullSensor orientation in android?

Try this: android:screenOrientation="fullSensor" The orientation is determined by the device orientation sensor. The orientation of the display depends on how the user is holding the device. This should be what you want. Also for more options check out this link-Activity Element.

How do I change the orientation of Android manifest?

The screen orientation attribute is provided by the activity element in the Android Manifest. Xml file. The orientations provided by the activity are Portrait, Landscape, Sensor, Unspecified and so on. To perform a screen orientation activity you define the properties in the Android Manifest.


2 Answers

In your manifest tag (just under xmlns:android="http://schemas.android.com/apk/res/android"), put

xmlns:tools="http://schemas.android.com/tools" 

Then inside the application tag, put

tools:ignore="LockedOrientationActivity" 
like image 57
Darragh MacKenna Avatar answered Oct 26 '22 18:10

Darragh MacKenna


it only affects Android Studio 3.6+

What is the Issue here? This issue occurs because android framework wants user to control the app orientation himself it is not advised to restrict your app orientation for example if a user wants to use the app in landscape orientation he just flips the device and sensors will do the work but when a developer restrict screen orientation, even when rotation sensor works app will stay in pre-defined state, in a way you are restricting user's device capabilities.

What to do now? You have two options., First is to ignore the error as it won't cause any build failure even I am doing the same and apk/aab generation is as usual Another Option is to provide Landscape Layouts or to handle the rotation like in some apps which recognize if orientation gets changed they will prompt the user to change the orientation as the app is not supported in such orientation

It may change in future => at present it is not effecting our build process but it might change in future

like image 34
trinadh thatakula Avatar answered Oct 26 '22 18:10

trinadh thatakula