On Android 9.0 and higher, a Titanium window's UI may disappear when the system's battery optimizer turn on or off. This can happen if the XML activities defined in the "tiapp.xml" are missing "android:configChanges" value "uiMode".
This issue can be reproduced consistently in an Android 9 (API 28) emulator.
Steps to reproduce:
- Create a new Titanium Classic "Default Project".
- Build and run on an Android 9 (aka: API 28) emulator.
- In the Android emulator's toolbar, click the "..." button.
- An "Extended Controls" window will open next to the emulator.
- Click on the "Battery" tab in this window.
- Go to the "Charge level" and lower it to 10%.
- Click the "Charge connection" drop-down and change it from "AC charger" to "None" (or vice-versa).
- In the emulator, if it asks if you want to enable the battery optimizer, tap "Yes".
- Notice that the Titanium app's UI disappears.
- Press the Android "Back" button.
- Relaunch the app. (The UI will appear as normal.)
- Click the emulator's "Charge connection" drop-down and change it back to "AC charger".
- Notice that the Titanium app's UI disappears again.
The "AndroidManifest.xml" that is being generated by Titanium's build system is missing a setting. We need to add "uiMode" to every Titanium <activity/> elements "android:configChanges" attribute.
You can work-around this issue by adding the following "activity" XML settings to the "tiapp.xml" file. The key thing here is to add all of the missing "configChanges" values. Particularly the "uiMode" value which solves this ticket's specific issue.