[TIMOB-26777] Android: Window UI disappears when connecting/disconnecting keyboard
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2019-05-29T17:42:11.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 8.0.2 |
Components | Android |
Labels | android, engSchedule, keyboard, manifest, tiapp.xml |
Reporter | Joshua Quick |
Assignee | Joshua Quick |
Created | 2019-01-29T22:58:27.000+0000 |
Updated | 2019-05-29T17:42:11.000+0000 |
Description
*Summary:*
The Titanium window UI will disappear when doing the following on Android:
* Connect or disconnect a bluetooth keyboard.
* Open or close a phone's slide-out keyboard. (Like the old Droid devices.)
*Steps to reproduce:*
Connect a bluetooth keyboard to an Android device.
Launch a Titanium app on that device.
Turn off the bluetooth keyboard (or pull the batteries out).
*Result:* The UI disappears when the keyboard disconnects. *Cause:* Titanium generates an "AndroidManifest.xml" when doing an Android build. The Titanium<activity/>
elements have an "android:configChanges" attribute which are missing the "keyboard" value. This is needed to override the Android OS' default behavior of destroying the activity and recreating it when a keyboard disconnects. (We overriding the "orientation" change event for the same reason.)
https://developer.android.com/guide/topics/manifest/activity-element#config
*Recommended Solution:*
We need to updating Titanium's "AndroidManifest.xml" template and/or "_build.js" to automatically add the "keyboard" setting to all activities that do not load UI from XML such as the root activity, TiActivity, JSActivity, etc.
*Work-Around:*
Add the following to the "tiapp.xml" to override the the "keyboard" handling yourself. Note that the activity name is based on the app's name. If the app's name is "MyAppName", then the activity name will be "MyappnameActivity".
<?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=".MyappnameActivity" android:configChanges="keyboard|keyboardHidden|orientation|fontScale|screenSize|smallestScreenSize|screenLayout|density">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="org.appcelerator.titanium.TiActivity" android:configChanges="keyboard|keyboardHidden|orientation|fontScale|screenSize|smallestScreenSize|screenLayout|density"/>
</application>
</manifest>
</android>
</ti:app>
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10884
PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10900
FR passed. jenkin is failing test. waiting for resolving jenkin failure to merge
Verified the fix on SDK 8.0.2.v20190525084235 and 8.1.0.v20190524131922. no window dispappears when bluetooth keyboard connected/disconnected. Works as expected.