Android 获取默认输入法,以及获取输入法的列表的方法

//获取默认输入法包名:
private String getDefaultInputMethodPkgName(Context context) {
    String mDefaultInputMethodPkg = null;

    String mDefaultInputMethodCls = Settings.Secure.getString(
            context.getContentResolver(),
            Settings.Secure.DEFAULT_INPUT_METHOD);
    //输入法类名信息
    Log.d(TAG, "mDefaultInputMethodCls=" + mDefaultInputMethodCls);
    if (!TextUtils.isEmpty(mDefaultInputMethodCls)) {
        //输入法包名
        mDefaultInputMethodPkg = mDefaultInputMethodCls.split("/")[0];
        Log.d(TAG, "mDefaultInputMethodPkg=" + mDefaultInputMethodPkg);
    }
    return mDefaultInputMethodPkg;
}


public void getList(){
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    List methodList = imm.getInputMethodList();
    for(InputMethodInfo mi : methodList ) {
        CharSequence name = mi.loadLabel(getPackageManager());
        Log.d(TAG, "getList: +"+name+ mi.getId());
    }
}

 

https://bbs.csdn.net/topics/391815609?page=1

https://www.cnblogs.com/onelikeone/p/7582836.html

你可能感兴趣的:(4,android,应用,系统开发)