Reliably getting screenSize configChanges in popup mode on tablet

I’m working on an activity containing a WebView, which means re-creating that activity is a fairly expensive operation (and causes user annoyance). The app is targeted at tablet users so it’s not uncommon for them to view it in a popup window in One UI. Currently, when the user resizes the popup, the activity sometimes adjusts (with onConfigurationChanged) but sometimes gets destroyed and recreated. There appear to be certain width/height breakpoints built in to One UI that trigger the activity to be re-created (without warning) no matter what the AndroidManifest says.

My Activity manifest has the following fields on it:

android:configChanges="orientation|screenSize|keyboardHidden|smallestScreenSize|uiMode"
android:resizeableActivity="true"

I also added this Application metadata, just to try everything:

<meta-data android:name="android.supports_size_changes" android:value="true" />

My tablet is a Galaxy S5e with One UI 3.1 on Android 11.

Ideally I’d like the activity to never get re-created when resizing (everything is fully responsive). If not that, I’d at least like a warning before the activity gets destroyed so I can persist the WebView instance in memory.

I haven’t been able to find any documentation about config changes or lifecycle events relating to One UI popups. Does anybody have pointers?

Hi, first of all, you cannot avoid destroying activity during the transition.

However, you can handle that and show a warning. You can check the below resources to get more information.

Thank you

Thanks for the reply! With my current code I’m not even able to handle it because the activity gets destroyed before onConfigurationChanged is called. Is there some other way I can do that?