【GB】提供简单的samplecode,如默认将俄语、英文、法语悔锋输入法勾选:1.新增文件LatinImeReceiver.JAVApackagecom.android.inputmethod.latin;importandroid.content.BroadcastReceiver;importandroid.content.Context;importandroid.content.Intent;importandroid.content.SharedPreferences;importandroid.content.SharedPreferences.Editor;importandroid.preference.PreferenceManager;importandroid.provider.Settings;importandroid.util.Log;importandroid.view.inputmethod.InputMethodInfo;importandroid.view.inputmethod.InputMethodManager;//importandroid.view.inputmethod.InputMethodSubtype;importandroid.text.TextUtils;publicclassLatinImeReceiverextendsBroadcastReceiver{privatestaticfinalStringTAG=LatinImeReceiver.class.getSimpleName();@OverridepublicvoidonReceive(Contextcontext,Intentintent){Log.d("LatinImeReceiver","step1");SharedPreferencessp=context.getSharedPreferences("com.android.inputmethod.latin_preferences",Context.MODE_PRIVATE);booleanhasSet=sp.getBoolean("has_set",false);if(!hasSet){Log.d("LatinImeReceiver"简顷,"step2");Editoreditor=sp.edit();Log.d("LatinImeReceiver","step3");editor.putString(LatinIME.PREF_SELECTED_LANGUAGES,"en_US,ru,fr");//默认将碧咐晌英语、俄语勾选,具体该怎么写可以参考inputlanguageselection.java中的WHITELIST_LANGUAGESeditor.putBoolean("has_set",true);Log.d("LatinImeReceiver","step4");
标签:输入法,Android,LatinIME