Android's simplest mobile map app (just 5 minutes)

Source: Internet
Author: User

Android's simplest mobile map app--has only three parts.


The first part

first set up a mapactivity in Setcontentview (r.layout. Activity_map ); Create a <webview> code as follows. 
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "    xmlns:tools=" Http://schemas.android.com/tools "    android:layout_width=" Match_parent    " android:layout_height= "Match_parent"    tools:context= "com.example.jreduch7292.MapActivity" ><webview    android:layout_width= "match_parent"    android:layout_height= "match_parent"    android:id= "@+id/wv1"    ></WebView></RelativeLayout>

Part II

Write the following code in Mapactivity:
Package Com.example.jreduch7292;import Android.support.v7.app.appcompatactivity;import Android.os.Bundle;import Android.webkit.webchromeclient;import Android.webkit.websettings;import Android.webkit.webview;import Android.webkit.webviewclient;public class Mapactivity extends Appcompatactivity {    @Override    protected void OnCreate (Bundle savedinstancestate) {        super.oncreate (savedinstancestate);        Setcontentview (R.LAYOUT.ACTIVITY_MAP);        WebView wv= (WebView) Findviewbyid (R.ID.WV1);        WebSettings ws=wv.getsettings ();        Ws.setdisplayzoomcontrols (true);        Ws.setsupportzoom (true);        Ws.setjavascriptenabled (true);        Wv.setwebviewclient (New Webviewclient ());        Wv.setwebchromeclient (New Webchromeclient ());        Wv.loadurl ("http://m.amap.com/?q=31.234527,121.287689");}    }

Part III

adding network permissions in the Androidmanifest.xml manifest file allows you to

<uses-permission android: name="Android.permission.INTERNET"/ >

Network permissions

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/ Android "package=" com.example.jreduch7292 "> <uses-permission android:name=" Android.permission.INTERNET "/ > <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> <application androi D:allowbackup= "true" android:icon= "@mipmap/ic_launcher" android:label= "@string/app_name" Android:supp Ortsrtl= "true" android:theme= "@style/apptheme" > <activity android:name= ". Viewpageractivity "/> <activity android:name=". Bujuactivity "></activity> <activity android:name=". Mapactivity "> <intent-filter> <action android:name=" Android.intent.action.MAIN "/&gt                ; <category android:name= "Android.intent.category.LAUNCHER"/> </intent-filter> </activity&    Gt </application></manifest>






Android's simplest mobile map app (just 5 minutes)

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.