Android Baidu Map (see Baidu Open Platform for details)

Source: Internet
Author: User

Compile files (' Libs/baidulbs_android.jar ')
Compile ' com.android.support:appcompat-v7:26.+ '
Compile ' com.android.support.constraint:constraint-layout:1.0.2 '
Testcompile ' junit:junit:4.12 '

<uses-permission android:name= "Com.android.launcher.permission.READ_SETTINGS"/>
<!--This permission is used for network positioning--
<uses-permission android:name= "Android.permission.ACCESS_COARSE_LOCATION"/>
<!--this permission to access GPS location--
<uses-permission android:name= "Android.permission.ACCESS_FINE_LOCATION"/>
<!--used to access WiFi network information, WiFi information is used for network location--
<uses-permission android:name= "Android.permission.ACCESS_WIFI_STATE"/>
<!--get carrier information to support interfaces that provide operator information--
<uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE"/>
<!--to read the current state of the phone--
<uses-permission android:name= "Android.permission.READ_PHONE_STATE"/>
<!--write extended storage, write data to the expansion card for writing offline location data--
<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>
<!--access network, network location needs internet--
<uses-permission android:name= "Android.permission.INTERNET"/>

Write your own android:name= ". Application. MyApplication "

<application
Android:name= ". Application. MyApplication "
Android:allowbackup= "true" >

 Packagenet.bwie.baidumap.application;Importandroid.app.Application;ImportCom.baidu.mapapi.SDKInitializer; Public classMyApplicationextendsApplication {@Override Public voidonCreate () {Super. OnCreate (); //initializes the context information before using each component of the SDK, passing in the ApplicationContext//Note that this method should be implemented before setcontentview the methodsdkinitializer.initialize (Getapplicationcontext ()); }}
 package   net.bwie.baidumap.activity;  import   android.support.v7.app.AppCompatActivity;  import   Android.os.Bundle;  import   NET.BWIE.BAIDUMAP.R;  public  class  basemapactivity extends   appcompatactivity {@ Override  protected  void   OnCreate (Bundle savedinstancestate) { super  .oncreate (savedinstancestate);    Setcontentview (R.LAYOUT.ACTIVITY_BASE_MAP); }}
Package Net.bwie.baidumap.activity;import Android.content.intent;import Android.os.bundle;import Android.support.v7.app.appcompatactivity;import Android.view.view;import Android.widget.button;import Net.bwie.baidumap.r;public class Mainactivity extends Appcompatactivity implements View.onclicklistener {    protected Button mbasemapbtn;    @Override    protected void onCreate (Bundle savedinstancestate) {        super.oncreate (savedinstancestate);        Super.setcontentview (r.layout.activity_main);        Initview ();    }    @Override public    void OnClick (view view) {        Intent Intent = new Intent ();        if (view.getid () = = r.id.base_map_btn) {            Intent.setclass (this, basemapactivity.class);        }        StartActivity (intent);    }    private void Initview () {        mbasemapbtn = (Button) Findviewbyid (R.ID.BASE_MAP_BTN);        Mbasemapbtn.setonclicklistener (mainactivity.this);    }}

  

Android Baidu Map (see Baidu Open Platform for details)

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.