How to get ID of user set default keyboard in Android -
i want make button in custom keyboard when pressed switch keyboard default user keyboard. have figured out how set input keyboard this:
final string latin = "com.android.inputmethod.latin/.latinime"; final ibinder token = this.getwindow().getwindow().getattributes().token; imm.setinputmethod(token, latin);
in case, pressing button want implement switch keyboard default user specified keyboard (latin keyboard).
the problem in particular example string given.
how find string of id of default user specified keyboard can set inputmethod
.
you can active keyboard's id in following example:
string id = settings.secure.getstring( getcontentresolver(), settings.secure.default_input_method)
if soft keyboard being used input, above code return keyboard's id.
but, can this: when input picker button clicked, can show list of input methods, , let user choose whatever input method likes:
inputmethodmanager inputmanager = (inputmethodmanager) this.getbasecontext().getsystemservice(context.input_method_service); inputmanager.showinputmethodpicker();
the above code open system dialog input method can picked. also, can list of input methods in code below:
inputmethodmanager imm = (inputmethodmanager) getsystemservice(context.input_method_service); list<inputmethodinfo> minputmethodproperties = imm.getenabledinputmethodlist(); final int n = minputmethodproperties.size(); (int = 0; < n; i++) { inputmethodinfo imi = minputmethodproperties.get(i); log.d("tag", "input method id: "+ getapplicationcontext().getpackagename(); }
Comments
Post a Comment