Search code examples
shelladbandroid-softkeyboardandroid-things

How to show soft keyboard on Android Things?


I'm trying to show soft keyboard on Android Things, Raspberry Pi 3. I tried the methods below, but not succeeded so far:

<activity
       ...
       android:windowSoftInputMode="stateAlwaysVisible">

and

<EditText
        ...
        android:inputType="numberDecimal"/>

Does Android Things 7.0 support soft keyboard, or am I missing something?


Solution

  • Update II: there is a bug with Dev Preview 5.1 when Google's soft keyboard doesn't show up at all.

    Update: starting with Dev Preview 4 the Android Things image is shipped with com.google.android.inputmethod.latin preinstalled. If you're going to use a 3d party keyboard app the approach below is still valid.


    You should enable the IME in Android Things Developer Preview in order for it to show up. Let's consider Google Keyboard as an example (since it worked for you). Once the keyboard has been installed and you shell-ed in (with adb shell) the following options might be used:


    Command line solution

    • Find out the IME ID

      $ ime list -a | grep mId
      
    • Enable the IME using the fully qualified mId

      Android Things 0.5+ (you might get already enabled)

      $ ime enable com.android.inputmethod.latin/.LatinIME
      

      Android Things 0.1 - 0.4:

      $ ime enable com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME
      

    Note: If you'd like to use the IME "app-wide" (not "system-wide"), use ime set ID instead of ime enable ID.


    Settings app solution

    Android Things 0.5+:

        am start -n com.android.settings/.Settings\$SystemDashboardActivity
    

    Languages & Input -> Virtual keyboard -> Manage keyboards and enable the IME (should already be enabled)

    Android Things 0.1 - 0.4:

        am start -n com.android.settings/.Settings\$InputMethodAndLanguageSettingsActivity
    

    Virtual keyboard -> Manage keyboards and enable the IME

    Note: In order to close _Android_'s settings app from within shell you can emulate a back button press multiple times with input keyevent 4 or force close the app with am force-stop com.android.settings.