android 6.0 默认输入法,Android6.0 设置默认输入法

Android6.0设置默认输入法,这里以日文输入法为例,

1.在frameworks/base/packages/SettingsProvider/res/values/defaults.xml 添加:

jp.co.omronsoft.openwnn/.OpenWnnJAJP2.在frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java添加:

loadStringSetting(stmt, Settings.Secure.DEFAULT_INPUT_METHOD,R.string.def_input_method );这个方法加在private void loadSecureSettings(SQLiteDatabase db)这个里面。

3.使能所有输入法,frameworks/base/core/java/com/android/internal/inputmethod/InputMethodUtils.java

--- a/frameworks/base/core/java/com/android/internal/inputmethod/InputMethodUtils.java

+++ b/frameworks/base/core/java/com/android/internal/inputmethod/InputMethodUtils.java

@@ -926,7 +926,7 @@ public class InputMethodUtils {

// At the initial boot, the settings for input methods are not set,

// so we need to enable IME in that case.

public void enableAllIMEsIfThereIsNoEnabledIME() {

- if (TextUtils.isEmpty(getEnabledInputMethodsStr())) {

+ if (!TextUtils.isEmpty(getEnabledInputMethodsStr())) {

StringBuilder sb = new StringBuilder();

final int N = mMethodList.size();

for (int i = 0; i < N; i++) {

这里的jp.co.omronsoft.openwnn/.OpenWnnJAJP是输入法ID,每个输入法都有自己的ID,如果不知道输入法ID,可以通过下面的打印方法获取:

frameworks/base/services/core/java/com/android/server/InputMethodManagerService.java

void buildInputMethodListLocked(ArrayList list,

HashMap map, boolean resetDefaultEnabledIme) {

if (DEBUG) {

Slog.d(TAG, "--- re-buildInputMethodList reset = " + resetDefaultEnabledIme

+ " \n ------ \n" + InputMethodUtils.getStackTrace());

}

list.clear();

map.clear();

// Use for queryIntentServicesAsUser

final PackageManager pm = mContext.getPackageManager();

String disabledSysImes = mSettings.getDisabledSystemInputMethods();

if (disabledSysImes == null) disabledSysImes = "";

final List services = pm.queryIntentServicesAsUser(

new Intent(InputMethod.SERVICE_INTERFACE),

PackageManager.GET_META_DATA | PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS,

mSettings.getCurrentUserId());

final HashMap> additionalSubtypes =

mFileManager.getAllAdditionalInputMethodSubtypes();

for (int i = 0; i < services.size(); ++i) {

ResolveInfo ri = services.get(i);

ServiceInfo si = ri.serviceInfo;

ComponentName compName = new ComponentName(si.packageName, si.name);

if (!android.Manifest.permission.BIND_INPUT_METHOD.equals(

si.permission)) {

Slog.w(TAG, "Skipping input method " + compName

+ ": it does not require the permission "

+ android.Manifest.permission.BIND_INPUT_METHOD);

continue;

}

if (DEBUG) Slog.d(TAG, "Checking " + compName);

//打印添加在这里,打印所有输入法的ID

Slog.d(TAG, "Checking packageName:" + si.packageName + " name:" + si.name);

try {

InputMethodInfo p = new InputMethodInfo(mContext, ri, additionalSubtypes);

list.add(p);

final String id = p.getId();

map.put(id, p);

if (DEBUG) {

Slog.d(TAG, "Found an input method " + p);

}

重新编译,烧录测试ok。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值