• android修改默认输入法


    方案一:adb命令设置?
    方案2:系统配置;
    方案3:调用系统API接口设置
    ---------------------------
    adb shell cmd
    adb root
    adb remount
    adb push xx.apk /system/app  
    ---------------------------

    #Android键盘(AOSP) ~ 系统默认
    com.android.inputmethod.latin/.LatinIME

    #谷歌拼音输入法
    com.google.android.inputmethod.pinyin/.PinyinIME

    #谷歌Gboard输入法
    com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME

    #触宝输入法国际版
    com.cootek.smartinputv5/com.cootek.smartinput5.TouchPalIME

    #Go 输入法
    com.jb.emoji.gokeyboard/com.jb.gokeyboard.GoKeyboard

    #SwiftKey Keyboard 输入法
    com.touchtype.swiftkey/com.touchtype.KeyboardService

    #搜狗输入法:
    com.sohu.inputmethod.sogou/.SogouIME

    #微软必应输入法
    com.bingime.ime/.BingIme

    ---------------------------
    #显示系统安装的输入法列表
    adb shell ime list -s

    #获取系统默认输入法
    adb shell settings get secure default_input_method

    #设置系统默认输入法
    adb shell settings put secure default_input_method com.touchtype.swiftkey/com.touchtype.KeyboardService

    示例:

    设置输入法为默认输入法

    adb shell settings put secure default_input_method com.cootek.smartinputv5/com.cootek.smartinput5.TouchPalIME

    adb shell settings put secure default_input_method com.jb.emoji.gokeyboard/com.jb.gokeyboard.GoKeyboard

    adb shell settings put secure default_input_method com.touchtype.swiftkey/com.touchtype.KeyboardService

    adb shell settings put secure default_input_method com.sohu.inputmethod.sogou/.SogouIME

    adb shell settings put secure default_input_method com.bingime.ime/.BingIme

    ---------------------------
    关于国际化的输入法:(一个输入法apk可以同时满足中英日韩等不同国家语言文字输入

    就目前测试了一圈,比较好用的有:

    • 触宝输入法国际版
    • Go 输入法
    • SwiftKey  // 被微软收购的

    另外还有Swype(华为手机预置的输入法,现在已不再更新了)

    其他:
    Swype输入法 --安装后点击桌面相应图标后启用该输入法,下载中文、日文等语言包

    SwiftKey 输入法支持的国家语言(中日韩英等……)
    https://support.swiftkey.com/hc/en-us/articles/201598431-What-languages-are-currently-supported-for-SwiftKey-on-Android-

    触宝输入法国际版 --有广告?
    必应输入法 ? ---经过实验,发现必应输入法无法输入日语等,放弃!
    ---------------------------

     代码实现输入法默认设置:

    import android.provider.Settings;//导入包
    // compile 'com.jakewharton.timber:timber:2.7.1'
    
    public class InputMethodUtil {
            /**
         * 若触宝输入法已安装,则设其为系统默认输入法
         * (写入Android系统数据库)
         */
        public static void setDefaultInputMethod(Context context) {
            //获取系统已安装的输入法ID
            String[] methods = getInputMethodIdList(context);
            if (methods == null || methods.length == 0) {
                Timber.w(String.format("found no input method."));
                return;
            }
    
            //检查是否安装触宝输入法
            //触宝输入法ID "com.cootek.smartinputv5/com.cootek.smartinput5.TouchPalIME";
            String targetKeyword = "TouchPal";
            String value = "";
            for (String m : methods){
                Timber.d(String.format("find : %s", m));
                if (m.toLowerCase().contains(targetKeyword.toLowerCase())){
                    value = m;//找到触宝输入法
                }
            }
            if (value == "") {
                Timber.w(String.format("didn't find " + targetKeyword));
                return;
            }
    
            //设置默认输入法
            String key = Settings.Secure.DEFAULT_INPUT_METHOD;
            boolean success = Settings.Secure.putString(context.getContentResolver(), key, value);
            Timber.d(String.format("writeDbDefaultInputMethod(%s),result: %s", value,success));
    
            //读取默认输入法
            String current = Settings.Secure.getString(context.getContentResolver(),key);
            Timber.d(String.format("current default: %s",current));
        }
    
        /**
         * 获取系统已安装的输入法ID
         * @param context
         * @return
         */
        public static String[] getInputMethodIdList(Context context) {
            InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
            if (imm != null && imm.getInputMethodList() != null) {
                String[] methodIds = new String[imm.getInputMethodList().size()];
                for (int i = 0; i <imm.getInputMethodList().size(); i++) {
                    methodIds[i] = imm.getInputMethodList().get(i).getId();
                }
                return methodIds;
            }
            return new String[]{};
        }
    }

    ref:

    Enabling third party input methods in Android on Chrome OS
    https://nolirium.blogspot.com/2017/08/enabling-third-party-input-methods-in.html

  • 相关阅读:
    Ubuntu使用PBIS认证
    命令行运行Python脚本时传入参数的三种方式
    Python中调用shell
    Install chocolatey
    Configure vyatta
    Linux: Block Port With IPtables
    转:PHPStorm+XDebug进行调试图文教程
    转 Fira Code | 为写程序而生的字体
    转 [PHP]
    转:Drupal 如何得到字段的值?
  • 原文地址:https://www.cnblogs.com/bluestorm/p/9133688.html
Copyright © 2020-2023  润新知