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 ();
}