标签:
android 判断一个app是否是输入法
之前做一个app,需要列出手机中安装的所有包,包括系统apps,但是又需要过滤输入法,于是后来找到这种方法来判断输入法。
public static boolean isInputMethodApp(Context context, String strPkgName) { PackageManager pkm = context.getPackageManager(); boolean bIsIME = false; PackageInfo pkgInfo; try { pkgInfo = pkm.getPackageInfo(strPkgName, PackageManager.GET_SERVICES); ServiceInfo[] servicesInfos = pkgInfo.services; if(null != servicesInfos){ for (int i = 0; i < servicesInfos.length; i++) { ServiceInfo sInfo = servicesInfos[i]; if(null != sInfo.permission && sInfo.permission.equals("android.permission.BIND_INPUT_METHOD")){ Log.i("isInputMethodApp ", strPkgName); bIsIME = true; break; }; } } } catch (NameNotFoundException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return bIsIME; }
标签:
原文地址:http://www.cnblogs.com/listensong/p/4451538.html