3

I'm updating my Android apps to support multi-window mode in Android 7. Since the apps already handle rotation changes in onConfigurationChanged, I want to handle window size changes the same way. So, I've updated AndroidManifest.xml to include android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout" for my activities.

This works as expected when resizing the windows so my app takes up 2/3 or 1/2 of the screen: onConfigurationChanged is called, and my activity is not restarted. But when I resize my app to or from the 1/3 screen size (so my app takes only 1/3 of the screen and another app takes the remaining 2/3), the app behaves as if I didn't have those configChanges values: onConfigurationChanged is not called, and my activity is restarted.

I checked the possible values for configChanges, but didn't see anything else that looked relevant.

Is there any reason for it to work this way, or is this an Android bug? I'm running Android 7.1.2 on a Google Pixel C tablet.

arlomedia
  • 8,534
  • 5
  • 60
  • 108
  • "But when I resize my app to or from the 1/3 screen size (so my app takes only 1/3 of the screen and another app takes the remaining 2/3)" -- by this, do you mean that you were 1/2 the screen, then slid the divider so your activity was 1/3rd the screen? – CommonsWare May 23 '17 at 23:29
  • Yes. Or when I slid from 1/3 back to 1/2 again. – arlomedia May 23 '17 at 23:31

1 Answers1

14

Per the Preparing for multi-window blog post, the minimal set of configChanges you need to handle multi-window is:

android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"

You are missing smallestScreenSize, which occurs when the smallest width of your Activity changes.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • You nailed it! Will accept in 10 minutes when StackOverflow lets me. :-) – arlomedia May 23 '17 at 23:33
  • P.S. I'm really pleased to get an answer directly from a Google employee on this. Kudos to Google for doing this kind of outreach. – arlomedia May 23 '17 at 23:45
  • @arlomedia - happy to help! I've filed an internal docs bug as well to get it added to the [multi-window documentation page](https://developer.android.com/guide/topics/ui/multi-window.html) as well. – ianhanniballake May 23 '17 at 23:55
  • This is (among other things) still needlessly complicated. We want simple APIs that are explicit, minimal and to the point, provided out of the box. It's really annoying when you have to waste hours to eventually find out that you're missing a special flag or a special call that magically fixes 75% of your issues, and then spend another couple of hours to find a different magical flag to sort out the remaining 25%. At least AppCompat should be flexible enough to implement well designed APIs over default ones in Android SDK. – milosmns Nov 07 '17 at 00:00