Baidu map integration in Android

Application Creation Procedure

Access the API console page, if you are not logged in Baidu account, will enter the Baidu account login page, as shown below:


Login to the API Console

Login will jump to the API console service, as shown below:


Create new Key


Select Android SDK as a Platform


Configure the Application

After selecting “Android SDK” as the application type, you need to configure the application’s security code, as shown in the following figure:


Get the Security Code

Security code composition rules: Android signature certificate sha1 value + packagename For example:

The SHA1: BB: 0D: the AC: 74: D3: 21: the E1: 43: 67: 71: 9B: 62: 91: the AF: the A1: 66: 6E: 44: 5D: 75

Package name: com.baidumap.demo

After entering the security code, click “OK” to complete the configuration of the application, you will get a created Key, please keep your application Key. At this point you can use the new Key to complete your development work.

Project Configuration Method

Step 1:

In the project app / libs directory into baidumapapi_vX_X_X.jar package, in the src / main / directory new jniLibs directory, the project will automatically load the src directory so dynamic library, put as shown below , Note that the first three versions of jar and so must be the same, and to ensure that the use of a download folder in the two files, not different functional components of the jar or so cross-use.


So the configuration can also refer to the directory structure given demo, as shown below, in the app project path, the new libs, and in the libs directory into the corresponding different CPU architecture so the file. So the project does not automatically load the libs under so, need to compile the gradle, by adding the code: jniLibs.srcDir ‘libs’ to explain the path of the libs path.


Step 2:

Project configuration also need to integrate the jar package to their own projects, as shown in the figure above, into the libs directory. For each jar file, right – select Add As Library, into the project. Corresponding to the build.gradle generated project depends on the jar file description, as shown:


Jar configuration can also refer to eclipse method, the following operations:

Select File -> Project Structure from the menu bar.

In the Project Structure dialog box that pops up, select module, and then click the Dependencies tab.

Click on the green plus select File dependency. Then select the jar package to add to complete the above operation in the app directory under the build.gradle file, there will be the introduction of the class library, as shown above.

Show Baidu Map

Baidu map SDK for developers to provide a convenient interface to display Baidu map data, in the following steps, you can use in your application Baidu map data:

The first step: create and configure the project (see the specific methods of the project configuration section);

The second step: AndroidManifest add development key, the required permissions and other information;

  1. In the application to add development key
  2. Add the required permissions

    The third step, in the layout of the xml file to add the map control;

    The fourth step is to initialize the Context global variable that the SDK refers to when the application is created:

    Note: need to call before using the SDK various functional components
    SDKInitializer.initialize (getApplicationContext ()) ;, so we recommend that the method on the Application of the initialization method

    The fifth step, create a map Activity, manage the map life cycle;

After completing the above steps, run the program to display the following map in your application.



Greeshma Borad Android Developer

I am an Android Developer at Yudiz Solutions Pvt. Ltd. - a leading mobile app development company. Android programming has been my passion since i started my carrier and like adopting new technologies to maximize development efficiency and produce innovative applications.

Comments are closed.