Today, when modifying a bug, there is a problem, that is, after an application is uninstalled, the Super User permissions interface will still load the information about the application. When you modify, in order to facilitate, directly using the inside a load icon code as a condition, that is, if the application has been uninstalled, then this icon is not loaded in. However, others have pointed out the loophole of this method, because it is very likely that some applications themselves are not icons, although the likelihood of this situation is very small, but after all, this is a potential vulnerability. Then it is more rigorous, directly using the application installation or not to modify the judgment.
The code is as follows
ImportAndroid.content.pm.ApplicationInfo;ImportAndroid.content.pm.PackageManager;Importandroid.content.pm.PackageManager.NameNotFoundException;ImportAndroid.content.pm.PackageInfo;Importjava.util.List;Private Booleancheckapkexist (Context context, String PackageName) {if(PackageName = =NULL|| "". Equals (PackageName)) { return false; } FinalPackagemanager Packagemanager =Context.getpackagemanager (); List< packageinfo> pinfo = packagemanager.getinstalledpackages (0); List<String> PName =NewArraylist<string>(); if(pinfo! =NULL) { for(inti = 0; I < pinfo.size (); i++) {String pn=Pinfo.get (i). PackageName; Pname.add (PN); } } returnPname.contains (PackageName); }
Validation successful
android-package-determine if the installation application exists