2

I have this issue in my tablet device Android 8.1. This device has natural orientation is landscape

I have 2 activity :

A is configured with fullSensor, contains a recyclerview to load items with thumbnail image

B is portrait, contain a surfaceview

  <activity
        android:name="com.hdq.myapp.activities.AActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name="com.hdq.myapp.activities.BActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="fullSensor"
        android:theme="@style/AppTheme.NoActionBar">
  • Step 1 : Open activity A in landscape -> start Activity B : it rotate to portrait

  • Step 2 : Press Back button, it return to activity A and rotate to landscape

  • Step 3 : After that, it keep rotate to portrait immmdiately

  • Step 4 : Finally, it rotate to landscape again. 3 rotation in just 2 second

It's seem less happen out if A and B is very simple activity (no recylerview, no surfaceview). Just less than before.

This behavior is too weird and I'm not sure where it come from, maybe OS or somewhere my app. The onConfigurationdChanged() method was called 2 time. Another apps in this device are not happen like this. Do you have any idea about this? Is that a memory issue or something like that?

I update the profiler in my device : enter image description here

The red one is the first normal rotation. 2 yellow ones is redundant.

This is call chart :

enter image description here

quangkid
  • 1,287
  • 1
  • 12
  • 31
  • Take a look here https://stackoverflow.com/questions/47228194/android-8-1-screen-orientation-issue-flipping-to-landscape-a-portrait-screen – HasaDev Apr 09 '18 at 15:25
  • Hey, i have exactly same problem. Can you share how did you solved this? – Gaurav Jan 05 '20 at 07:16

1 Answers1

0

Try this:

<activity
     android:name="com.hdq.myapp.activities.AActivity"
     android:configChanges="locale|keyboard|keyboardHidden|orientation"
     android:windowSoftInputMode="stateAlwaysHidden|adjustResize|screenSize"
     android:theme="@style/AppTheme.NoActionBar">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />

          <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

    <activity
        android:name="com.hdq.myapp.activities.BActivity"
        android:configChanges="locale|keyboard|keyboardHidden|orientation|screenSize"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
        android:theme="@style/AppTheme.NoActionBar">
Viks
  • 1,510
  • 4
  • 22
  • 50