Configure other required permissions and keys:
Step 2: Add the development key, required permissions and other information in the AndroidManifest;
(1) Add the development key to the application
<meta-data android:name="com.baidu.lbsapi.API_KEY" android:value="developer key"> </meta-data>
(2) Add the required permissions
<activity android:name=".touchEvent.TouchEventActivity"/> <activity android:name=".jiami.Md5Activity"/> <activity android:name=".animation.AnimationActivity"/> <activity android:name=".animation.ViewAnimationActivity"/> <activity android:name=".animation.FrameAnimationActivity"/> <activity android:name=".thread.XianChengActivity"/> <activity android:name=".thread.HandleActivity"/> <activity android:name=".thread.HandlerProgressBarAitivity"/>
The third step is to add a map control in the layout xml file;
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.baidu.mapapi.map.mapview android:id="@+id/bmapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true"> </com.baidu.mapapi.map.mapview> </LinearLayout>
The fourth step is to initialize the Context global variable referenced by the SDK when the application is created;
public class MapActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate (savedInstanceState); SDKInitializer.initialize(getApplicationContext()); setContentView(R.layout.activity_map); } }
Note: SDKInitializer.initialize(getApplicationContext()); needs to be called before each functional component of the SDK is used.
Therefore, we recommend that this method be placed in the initialization method of the Application
3. Compile and run the installation apk:
I have built and installed the project directly in Gradle here.
Install and run the APK file:
Get the final result:
This interface appears to indicate that the environment is built, and you can continue to implement other map functions.