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; } |
热门源码