Android to determine if the app is installed, not installed to download the installation from the store

Source: Internet
Author: User

 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&region= 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.