The first ArcGIS-based Android app

Source: Internet
Author: User

Create your first project using Android Studio

Open Android Studio and create a new project. Fill in the project name at application name, company domain is the corporate address, and in the future as the package name, click Next Next.

Select Phone and Tablet,api Select 16 later (ArcGIS Tutorial this way, possible system requirements), click Next Next.

Select empty activity next.

Now that the project has been successfully created, the next step is to join the ArcGIS Runtime SDK dependency.

Add ArcGIS Runtime SDK dependencies

Using the Gradle script to add a path, the compressed package is downloaded automatically. Open the Build.gradle file under (Project) and add the code:

allprojects {    repositories {        jcenter ()        maven {            url ' https://esri.bintray.com/arcgis '    }}}

  

Add a dependency package, substituting (Module) for the Build.gradle file, and add the code:

dependencies {   compile ' com.esri.arcgisruntime:arcgis-android:100.1.0 '   compile Filetree (dir: ' Libs ', Include: [' *.jar '])  [more dependencies ...]}

Add permissions.

<?xml version="1.0"encoding="Utf-8"? ><manifest xmlns:android="http://schemas.android.com/apk/res/android" Package="Com.example.jimmy.displaymap"> <uses-permission android:name="Android.permission.INTERNET"/> <uses-feature android:glesversion="0x00020000"Android:required="true"/> <Application Android:allowbackup="true"Android:icon="@mipmap/ic_launcher"Android:label="@string/app_name"Android:roundicon="@mipmap/ic_launcher_round"Android:supportsrtl="true"Android:theme="@style/apptheme"> <activity android:name=". Mainactivity"> <intent-filter> <action android:name="Android.intent.action.MAIN"/> <category android:name="Android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application></manifest>

Add a layout to your app

On the Androidmanifest.xml file, add the code:

<com.esri.arcgisruntime.mapping.view.MapView  android:id="@+id/mapview"    android:layout_width="fill_parent"  Android:layout_ Height="fill_parent" ></ Com.esri.arcgisruntime.mapping.view.mapview>

Initialize Map

To add code on mainactivity:

Package Com.example.jimmy.displaymap;import Android.support.v7.app.appcompatactivity;import android.os.Bundle ; Import Com.esri.arcgisruntime.mapping.arcgismap;import Com.esri.arcgisruntime.mapping.view.mapview;import Com.esri.arcgisruntime.mapping.Basemap; Public classMainactivity extends Appcompatactivity {PrivateMapview Mapview; @Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main); Mapview=(Mapview) Findviewbyid (R.id.mapview); Arcgismap Map=NewArcgismap (Basemap.Type.TOPOGRAPHIC,26.893231,112.571997, -);    Mapview.setmap (map); } @Overrideprotected voidOnPause () {mapview.pause ();    Super.onpause (); } @Overrideprotected voidOnresume () {super.onresume ();    Mapview.resume (); }}

Run the program

Make Project and wait for the download to complete the package. Running the app with no errors shows the following:

There are watermarks on the map and links at the bottom.

The first ArcGIS-based Android app

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.