android 輸入法預設設定
設定預設輸入法
在 frameworks\base\core\res\res\values\config.xml 新增一個屬性:
<!--leo add-->
<string name="config_default_input_method">com.android.inputmethod.pinyin/.PinyinIME</string>
frameworks\base\services\java\com\android\server\InputMethodManagerService.java
的方法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 )
{
}
}
下面的方法也可:
設定預設輸入法為google拼音
\frameworks\base\packages\SettingsProvider\res\values\defaults.xml
<!-- leo add -->
<string name="config_default_input_method" translatable="false">com.android.inputmethod.pinyin/.PinyinIME</string>
\frameworks\base\packages\SettingsProvider\src\com\android\providers\settings\DatabaseHelper.java
private void loadSecureSettings(SQLiteDatabase db)
//leo add
loadStringSetting( stmt, Settings.Secure.DEFAULT_INPUT_METHOD,
R.string.config_default_input_method );