下面列出了android.view.inputmethod.InputMethodInfo#getServiceName ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void setDefaultInputMethod(InputMethodInfo info) {
// 设置默认输入法.
String packName = info.getPackageName();
String serviceName = info.getServiceName();
int lastIndex = serviceName.lastIndexOf(".");
if (lastIndex != -1) {
String setInfo = packName + "/" + serviceName.substring(lastIndex);
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD,
"" + setInfo);
}
}
public void setDefaultInputMethod(InputMethodInfo info) {
// 设置默认输入法.
String packName = info.getPackageName();
String serviceName = info.getServiceName();
int lastIndex = serviceName.lastIndexOf(".");
if (lastIndex != -1) {
String setInfo = packName + "/" + serviceName.substring(lastIndex);
Settings.Secure.putString(mContext.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD,
"" + setInfo);
}
}