*Succeded!!!*
The only way I have figured out of changing the current IME is by customizing it. For my resp. problem I have to change the keyboard to chinese if I change the system language to chinese from my custom Settings application. The approach discussed below was used in a custom *LatinIME* app. Every IME has a class that extends InputMethodService<http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html> class. In this class we can override a method called onInitializeInterface<http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html#onInitializeInterface%28%29>. This method gets called everytime when the configuration changes i.e. when you change your system Locale it will be called. Here we can check whether the Locale that's currently been selected is supported by the current IME or not. If not then we can load its respective IME by calling the method switchInputMethod(id)<http://developer.android.com/reference/android/inputmethodservice/InputMethodService.html#switchInputMethod%28java.lang.String%29> . To get the id, we can query through inputMethodManager<http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html> and get a list of available ids String pinyinId = ""; InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext() .getSystemService(INPUT_METHOD_SERVICE); List<InputMethodInfo> inputMethodInfos = inputMethodManager.getInputMethodList(); for (InputMethodInfo inputMethodInfo : inputMethodInfos) { if (inputMethodInfo.getId().contains("pinyin")) { pinyinId = inputMethodInfo.getId(); } } After getting the id we can call switchInputMethod(pinyinId) and it will change the IME. On Thursday, January 23, 2014 4:43:59 PM UTC+5:30, user1235555 wrote: > > I have a requirement of changing the keyboard based on the change of > language. > > I have done a bit of research and found that it can be done using these > APIs > > > 1. InputMethodManager setInputMethod(android.os.IBinder, > java.lang.String) > 2. InputMethodService switchInputMethod(java.lang.String) > > For the 1st API, I need an *IBinder token* which can be taken from > *InputMethodService* instance by calling > > mInputMethodService.getWindow().getWindow().getAttributes().token > > or if I have the reference to *InputMethodService* object I can simply > call > > mInputMethodService.switchInputMethod(id) > > to change the input method. > > *The real problem is how do I get a reference to InputMethodService > object.* > > *PS:* I don't want to use InputMethodManager's showInputMethodPicker() > because for my requirement I want to change it from my existing dialog > which has a list of languages. > > I know that this is not possible for a user app but not sure if it's also > not possible for a system app or not. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.