Android determines if an app is an input method
Before doing an app, need to list all the packages installed in the phone, including system apps, but also need to filter the input method, and then found this method to determine the IME.
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;}
Android determines if an app is an input method