Used to use Baidu API in the software to do a Baidu map out of this feeling is both a waste of time and waste of energy, here to teach you directly using the intent way to call the Baidu Map client installed on the phone, access to the path we need to plan, etc.
Tune up Baidu Map client try { intent = intent.getintent ("intent://map/direction?origin=latlng : 34.264642646862,108.95108518068|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", "Baidu Map client not Installed"); } } catch (URISyntaxException e) { e.printstacktrace ();}
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:
/** * Determine if target app is installed * @param packagename target app installed package name * @return If Target app is installed * / Private Boolean Isinstallbyread (String packagename) { return new File ("/data/data/" + PackageName). exists ();
We can have the flexibility to call Baidu map.
My intent is used for navigation. Other map functions are self-fulfilling (other functions need to be self-reference Baidu Url-api). Attached link: http://developer.baidu.com/map/uri-intro.htm#idmykey1
Call the Gold Map: (The other wording is the same only url-api different)
Intent = intent.getintent ("androidamap://path?sourceapplication=gasstation&sid=bgvis1&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 ");
Open source China seems to have no place to upload attachments, such as projects or anything. This is a little depressed, and he's looking for URL-API.
Android calls Baidu Map client,