Android calls Baidu Map client,

Source: Internet
Author: User

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,

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.