How to show soft keyboard on Android Things?

强颜欢笑 提交于 2020-01-09 10:07:19

问题


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?


回答1:


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.




回答2:


By default, keybord apps are not installed on AT Developer Preview. You have to install it. See software keyboard.



来源:https://stackoverflow.com/questions/42015209/how-to-show-soft-keyboard-on-android-things

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!