Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-26777

Android: Window UI disappears when connecting/disconnecting keyboard

    Details

    • Story Points:
      3
    • Sprint:
      2019 Sprint 11

      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:

      1. Connect a bluetooth keyboard to an Android device.
      2. Launch a Titanium app on that device.
      3. 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>
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Yordan Banev
                Tester:
                Keerthi Mahalingam (Inactive)
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-6863
                    Sync status:
                    PENDING
                    Last received:
                    Last sent:

                    Git Integration