开发者

how to set default IME in porting Android?

开发者 https://www.devze.com 2023-03-01 10:09 出处:网络
in build/target/product/generic.xml I add PinyinIME to add it to my build. in makefile I set CUSTOM_LOCALES:= zh_CN en_US and ADDITIONAL_BUILD_PROPERTIES := persist.sys.timezone=Asia/Shanghai persist
  • in build/target/product/generic.xml I add PinyinIME to add it to my build.
  • in makefile I set CUSTOM_LOCALES:= zh_CN en_US and ADDITIONAL_BUILD_PROPERTIES := persist.sys.timezone=Asia/Shanghai persist.sys.language=zh persist.sys.country=CN to make only US and CN available and set CN to be default.

But the phone's default IME is still LatinIME, though my default language setting is CN. In PinyinIME开发者_如何学Go, values-zh/bools.xmldoes contain <bool name="im_is_default">true</bool>

How to achieve my goal please?


a work around according to http://hi.baidu.com/wishwingliao/blog/item/65a2d03f7dde8dd17d1e71ec.html. in frameworks\base\core\res\res\values\config.xml add as below

<string name="config_default_input_method">com.android.inputmethod.pinyin/.PinyinIME</string>

in frameworks\base\services\java\com\android\server\InputMethodManagerService.java, add following in buildInputMethodListLocked()

String defaultIme = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
    //leo

    if ( defaultIme == null )
    {
        final Resources res = mContext.getResources();
        try
        {
            //frameworks\base\core\res\res\values\config.xml
            String myIME = res.getString( com.android.internal.R.string.config_default_input_method );
            if ( myIME != null && myIME.length() > 0 )
            {
               Settings.Secure.putString( mContext.getContentResolver(),
                        Settings.Secure.DEFAULT_INPUT_METHOD,
                        myIME );
            }
        }

        catch ( Exception e )
        {
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消