Start the application of Baidu map
First, you should download the SDK provided to us by Baidu, including the Development Kit sample code API
Sign in below address
Http://developer.baidu.com/map/index.php?title=%E9%A6%96%E9%A1%B5
These are based on their own development needs of their own decision to download, the situation allows all download is not much
1. Import the class library files required by the project
Unpack the development package
Enter the Libs directory below this jar needs
and the bottom-level library goes under the Armeabi directory.
A jar package is also required if you use the to locate feature
2. Configure developer key in the manifest file
<meta-data
Android:name= "Com.baidu.lbsapi.API_KEY"
Android:value= "The developer who introduced the application in the previous section, key"/>
The location of this node in the manifest file
3. Add Permissions
<uses-permissionandroid:name= "Android.permission.GET_ACCOUNTS"/>
<uses-permissionandroid:name= "Android.permission.USE_CREDENTIALS"/>
<uses-permissionandroid:name= "Android.permission.MANAGE_ACCOUNTS"/>
<uses-permissionandroid:name= "Android.permission.AUTHENTICATE_ACCOUNTS"/>
<uses-permissionandroid:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<uses-permissionandroid:name= "Android.permission.INTERNET"/>
<uses-permissionandroid:name= "Com.android.launcher.permission.READ_SETTINGS"/>
<uses-permissionandroid:name= "Android.permission.CHANGE_WIFI_STATE"/>
<uses-permissionandroid:name= "Android.permission.ACCESS_WIFI_STATE"/>
<uses-permissionandroid:name= "Android.permission.READ_PHONE_STATE"/>
<uses-permissionandroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permissionandroid:name= "Android.permission.BROADCAST_STICKY"/>
<uses-permissionandroid:name= "Android.permission.WRITE_SETTINGS"/>
<uses-permissionandroid:name= "Android.permission.READ_PHONE_STATE"/>
4. Add the Baidu map control to the layout file
< com.baidu.mapapi.map.mapview
android :id= "@ +ID/BAIDU_MV "
android :layout_width= "match_parent"
android : layout_height= "match_parent" ;
Span style= "background: #EFEFEF" ></ Com.baidu.mapapi.map.MapView ;
5.1 Show Map
Activity (for now, consider only the activity that follows fragment) incoming ApplicationContext initialization map before build initialization
Sdkinitializer.initialize (Getapplicationcontext ());
The best way to Cook is to customize a application in this to implement the above method
6. Managing the life cycle of a map
Onresume
OnPause
Ondestory
@OverrideSuperbaidumapview. Onresume ();} @Override Superbaidumapview. OnPause ();} @Override Superbaidumapview. OnDestroy ();}
By now we can show the map on the interface and we'll do the map again later.
The source code of the program is attached below
Click to open link
Baidu Map API Usage Series 2-Show Map