Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26777] Android: Window UI disappears when connecting/disconnecting keyboard

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-05-29T17:42:11.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.0.2
ComponentsAndroid
Labelsandroid, engSchedule, keyboard, manifest, tiapp.xml
ReporterJoshua Quick
AssigneeJoshua Quick
Created2019-01-29T22:58:27.000+0000
Updated2019-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>

Comments

  1. Joshua Quick 2019-05-11

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/10884
  2. Joshua Quick 2019-05-18

    PR (8.0.x): https://github.com/appcelerator/titanium_mobile/pull/10900
  3. Keerthi Mahalingam 2019-05-21

    FR passed. jenkin is failing test. waiting for resolving jenkin failure to merge
  4. Keerthi Mahalingam 2019-05-29

    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.
    Test Environment:
       Operating System
         Name                        = Mac OS X
         Version                     = 10.13.6
         Architecture                = 64bit
         # CPUs                      = 8
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 8.9.1
         npm Version                 = 5.5.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.0.2.v20190525084235 and 8.1.0.v20190524131922
       Device = pixel 2 android 9
       

JSON Source