Call Baidu Maps App

Source: Internet
Author: User

The code is as follows:
//Tune up Baidu map client
try {
Intent = intent.getintent ("intent://map/direction?origin=latlng:34.264642646862,108.95 108518068|name: My home &destination= Wild Goose Pagoda &mode=driving?ion= Xi ' an &referer=autohome| Gasstation#intent;scheme=bdapp;package=com.baidu.baidumap;end ");
if (Isinstallbyread ("Com.baidu.BaiduMap")) {
startactivity (intent);//Start Call
log.e ("Gasstation", "Baidu Map client has been installed");
}else{
log.e ("Gasstation", "No Baidu Map Client Installed");
                                }
} catch (URISyntaxException e) {
e.printstacktrace ();
} [/mw_shl_code]
However, if the client is not installed Baidu Map client will be reported no Activity .... Directly causes the program to hang up, which developers do not want to see. So before the call to determine whether the phone installed Baidu Map client, we know that Baidu's package named Com.baidu.BaiduMap
so the following method is used to judge:
[mw_shl_code=java,true]/**
* Determine if the target app is installed
* @param packagename target app installed package name
* @return If the target app is installed
         */    
Private Boolean Isinstallbyread (String packagename) {
return new File ("/data/data/" + PackageName). exists ();

}


Using intent to invoke the gold map


try {
Intent = intent.getintent ("ANDROIDAMAP://PATH?SOURCEAPPLICATION=GASSTATION&SID=BGV Is1&slat=34.264642646862&slon=108.95108518068&sname= Current Position &did=bgvis2&dlat=36.3&dlon= 116.2&dname= End Position &dev=1&m=2&t=0 ");
if (Isinstallbyread ("Com.autonavi.minimap")) {
startactivity (intent);//Start Call
log.i ("Gasstation", "Gold Map client already Installed");
}else{
log.d ("Gasstation", "No Gold Map Client Installed");
                                }
} catch (URISyntaxException e) {
//TODO auto-generated catch block
e.printstacktrace ();
                        }

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.