Rdb*_*ost 11 keyboard android ime android-softkeyboard android-8.0-oreo
我正在尝试创建多个IME子类型,但Android只能识别一个.
<?xml version="1.0" encoding="utf-8"?>
<input-method
xmlns:android="http://schemas.android.com/apk/res/android"
android:supportsSwitchingToNextInputMethod="true"
android:settingsActivity="com.example.softkeyboard.Settings">
<subtype android:name="@string/display_name_english_keyboard_dynamic_ime"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="charDataFile=strokemaps_dynamic" />
<subtype android:name="@string/display_name_english_keyboard_ime"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="charDataFile=strokemaps" />
</input-method>
Run Code Online (Sandbox Code Playgroud)
<resources>
<string name="app_name">KK1</string>
<string name="display_name_english_keyboard_ime">English</string>
<string name="display_name_english_keyboard_dynamic_ime">English Dynamic</string>
Run Code Online (Sandbox Code Playgroud)
@Override
public void onStartInputView(EditorInfo ei, boolean restarting) {
super.onStartInputView(ei, restarting);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
List<InputMethodInfo> imil = imm.getEnabledInputMethodList();
for (InputMethodInfo imi: imil) {
Log.e("osiv", "input method info: "+imi.toString());
}
List<InputMethodSubtype> imsl = imm.getEnabledInputMethodSubtypeList(imil.get(0), true);
for (InputMethodSubtype ims: imsl) {
Log.e("osiv", "input method subtype: "+ims.toString());
}
Run Code Online (Sandbox Code Playgroud)
列出的InputMethodInfos包含我的IME,但子类型列表只包含一个子类型.如果它是文件中唯一的子类型,则每个子类型都起作用.
Android 8.0设备不会在其语言/键盘配置选项中显示子类型,只显示IME本身,因此无法单独启用或禁用子类型.
是否有其他配置项需要告诉Android允许多个IME子类型?
上面的代码有明显的问题吗?
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.k.k.kk1">
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".KKInputMethodService"
android:permission="android.permission.BIND_INPUT_METHOD"
android:label="KK"
android:configChanges="orientation">
<intent-filter>
<action android:name="android.view.InputMethod"/>
</intent-filter>
<meta-data
android:name="android.view.im"
android:resource="@xml/method"/>
</service>
</application>
Run Code Online (Sandbox Code Playgroud)
似乎有一种方法可以更改 IME 子类型,即使用内置子类型选择器,该选择器似乎只能通过应用程序或 IME 的意图来使用。
\n\nfinal Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);\nintent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, imId);\nintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);\nintent.putExtra(Intent.EXTRA_TITLE, \xe2\x80\x9cSelect Enabled Subtypes\xe2\x80\x9d);\ncontext.startActivity(intent);\nRun Code Online (Sandbox Code Playgroud)\n\n如果您希望从 InputMethodService 中启动 Intent,则 FLAG 是必需的。
\n\n您可以从 inputMethodInfo 对象中获取输入法 ID \'imId\',方法是:
\n\nString imId = inputMethodInfo.getId(); \nRun Code Online (Sandbox Code Playgroud)\n\n或者您可以使用以下方式获取 id:
\n\nString imId = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);\nRun Code Online (Sandbox Code Playgroud)\n\n这个答案的核心来自:\n https://blog.swiftkey.com/tech-blog-android-input-method-subtypes/
\n| 归档时间: |
|
| 查看次数: |
594 次 |
| 最近记录: |