Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27141] Android 9: App not honoring the Orientation set for Windows.

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionInvalid
Resolution Date2019-08-20T17:00:32.000+0000
Affected Version/sRelease 8.0.1
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid9, Orientation, engSchedule
ReporterSharif AbuDarda
AssigneeGary Mathews
Created2019-06-07T21:20:38.000+0000
Updated2019-08-20T17:00:32.000+0000

Description

Hi Team, We are observing some abnormal behavior with “orientationModes” property of Ti.UI.Window. When we set orientationModes : [Titanium.UI.PORTRAIT] during window construction, the app is rotating to landscape, when “Auto-Rotate” is turned on in real time device. This is only happening with Android 9.0 and behaving properly on OS versions less than 9.0. The issue is reproducible using SDK 8.0.1.GA and lower release. Please find the attached sample to reproduce the issue. Steps to reproduce : 1. Turn on “Auto-Rotate” in Android device with OS 9 2. Run the app on the device. 3. Now hold device in landscape mode and navigate to next screen by tapping on the label. 4. *A new screen will initially load in landscape mode* then turns to Portrait mode. *Expected result :* New screen opens is Portrait mode. Then Run on Android device with OS < 9(Works as expected). Thanks in advance.

Attachments

FileDateSize
SampleApp.zip2019-06-07T21:18:58.000+00008644443

Comments

  1. Sharif AbuDarda 2019-06-07

    Hello, I was able to reproduce the issue using the attached sample code with SDK 8.0.1.GA in Android 9.0.1 device(Nokia 6). The issue isn't occurring in Android 6.0.1 device (Galaxy J2 Prime). Thanks.
  2. Joshua Quick 2019-06-28

    Interesting. It doesn't appear that this issue can be solved in native code. It can only be solved via the "AndroidManifest.xml" file. It looks like the Android OS is setting up the transition animation based on the activity's XML "screenOrientation" which supports all orientations by default. Other native developers are running into the same issue here... https://stackoverflow.com/questions/42936007/activity-orientation-changes-automatically-on-android If all of your app's windows are supposed to be portrait only, then you can solve this via the "tiapp.xml" and have all Titanium activity's be "portrait as follows. Note the "screenOrientation" attribute. This is what you need to set.
       <?xml version="1.0" encoding="UTF-8"?>
       <ti:app xmlns:ti="http://ti.appcelerator.org">
       	<android xmlns:android="http://schemas.android.com/apk/res/android">
       		<manifest>
       			<application>
       				<activity android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait" android:configChanges="fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode|density"/>
       				<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" android:screenOrientation="portrait" android:theme="@style/Theme.Titanium.Translucent" android:configChanges="fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode|density"/>
       			</application>
       		</manifest>
       	</android>
       </ti:app>
       
    If your app uses a mix of different orientations, then you may want to try setting the activity orientation to "behind" in XML, which tells the Android OS to use the parent activity's orientation for the child activity. This solves the issue in your app as well. Although I don't have much experience with that setting, so, I'm not sure if there are any unexpected repercussions with it.
       <?xml version="1.0" encoding="UTF-8"?>
       <ti:app xmlns:ti="http://ti.appcelerator.org">
       	<android xmlns:android="http://schemas.android.com/apk/res/android">
       		<manifest>
       			<application>
       				<activity android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="behind" android:configChanges="fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode|density"/>
       				<activity android:name="org.appcelerator.titanium.TiTranslucentActivity" android:screenOrientation="behind" android:theme="@style/Theme.Titanium.Translucent" android:configChanges="fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode|density"/>
       			</application>
       		</manifest>
       	</android>
       </ti:app>
       
  3. Sharif AbuDarda 2019-07-02

    Hello [~jquick], I got a reply from the customer on your guide, As suggested we have mentioned the android:screenOrientation="portrait" attribute to each and every activity in the tiapp.xm. When we set the "theme" property for the window as theme: "Theme.AppCompat.Translucent.NoTitleBar" and set targetSdkVersion to 28 apps is getting crashed on Android OS 8.0.0 only. It is working as expected in rest of the Android OS versions. We are using Ti 8.0.1.GA SDK. It is printing below error log : [ERROR] : E/ViewRootImpl@e2250eb[ScreenrotationappandroidActivity]: Surface is not valid. [DEBUG] : AndroidRuntime: Shutting down VM [ERROR] : TiExceptionHandler: (main) [134,134] Unable to start activity ComponentInfo{com.rotation.api/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation [ERROR] : TiExceptionHandler: [ERROR] : TiExceptionHandler: android.app.Activity.onCreate(Activity.java:1038) [ERROR] : TiExceptionHandler: android.support.v4.app.SupportActivity.onCreate(SupportActivity.java:66) [ERROR] : TiExceptionHandler: android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:321) [ERROR] : TiExceptionHandler: android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:84) [ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:699) [ERROR] : TiExceptionHandler: org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:47) [ERROR] : TiExceptionHandler: android.app.Activity.performCreate(Activity.java:7183) [ERROR] : TiExceptionHandler: android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) [ERROR] : TiExceptionHandler: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908) [ERROR] : TiExceptionHandler: android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030) [ERROR] : TiExceptionHandler: android.app.ActivityThread.-wrap11(Unknown Source:0) [ERROR] : TiExceptionHandler: android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) [ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:105) [ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:164) [ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:6938) [ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiExceptionHandler: com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) [ERROR] : TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Thanks in advance.
  4. Joshua Quick 2019-07-02

JSON Source