Public Static Booleanisavilible (Context context, String PackageName) {FinalPackagemanager Packagemanager = Context.getpackagemanager ();//Get Packagemanagerlist< packageinfo> pinfo = packagemanager.getinstalledpackages (0);//Get package information for all installed programsList<string> PName =NewArraylist<string> ();//the package name used to store all installed programs//Remove the package name from pinfo and press it into the PName list if(pinfo! =NULL){ for(inti = 0; I < pinfo.size (); i++) {String pn=Pinfo.get (i). PackageName; Pname.add (PN); } } returnPname.contains (PackageName);//determine if there is a package name for the target program in PName, there is true, no false}
if(Baidutool.isavilible (setting_activity. This. Getapplicationcontext (), "Com.baidu.BaiduMap")){ Try{Intent= Intent.getintent ("INTENT://MAP/DIRECTION?ORIGIN=LATLNG:" +baidutool.getinstance (). Getlocationx () + "," + Baidutool.getinstance (). Getlocationy () + "|name: My location &destination= &mode=transit®ion= Qingdao &src= Mobile Medical Care #intent;scheme=bdapp;package=com.baidu.baidumap;end "); } Catch(URISyntaxException e) {toastutils.show (Getapplicationcontext (),"Call Baidu Map failed."); LOG.I ("Baidutoolisavilible", "Not Installed"); } startactivity (Intent); } //not installed, jump to market download the program Else { //Baidu Map is not installed, jump to the App store.Toastutils.show (Getapplicationcontext (), "Baidu maps not installed, jump App Store."); Uri URI= Uri.parse ("Market://details?id=com.baidu.baidumap");//ID is the package nameIntent it =NewIntent (Intent.action_view, URI); StartActivity (IT); } //mobile app to tune up Android Baidu map Way Example
Android to determine if the app is installed, not installed to download the installation from the store