1, my Android version is: Android4.4.2.
2, my arcgisandroidsdk is: arcgis-android-sdk-v10.2.3.
One, Map publishing
The first thing you need to do is publish the map service in Arccatalog (or ArcGIS Server Manager, which looks like you need to share the folder). How to publish it is needless to note that:
1) Coordinate system Select ' Projected coordinate system ', ' World ' under 'wgs_1984_web_mercator';
2) You need to select 'Mobile Data Access' in the ' Capabilities ' tab of the ' Service Editor ' dialog box.:
Two, create ArcGIS Project for Android in Eclipse
1, in the "Package Explore" area, right click "New", "Project", select "Arcgis for Android" item:
2. Click "Next" and enter the appropriate project name:
,
3, click "Next", enter the appropriate package name, click Done, (here to select the appropriate target SDK):
,
4, when finished, the resulting package view is:
Three, loading the map
1, from the end of the second step, Eclipse creates the default activity (here is ' Arcgisandroidofflineactivity.java '), double-click to open the. java file and modify it to:
1 PackageJuk.demos;2 3 Importandroid.app.Activity;4 ImportAndroid.os.Bundle;5 ImportAndroid.view.ViewGroup.LayoutParams;6 7 ImportCom.esri.android.map.MapView;8 ImportCom.esri.android.map.ags.ArcGISDynamicMapServiceLayer;9 Ten One Public classTryofflineactivityextendsActivity { A - Mapview Mmapview; - the /**Called when the activity is first created.*/ - @Override - Public voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.main); - + //-----Manually added sections A atMmapview =NewMapview ( This); -Mmapview.setlayoutparams (Newlayoutparams (layoutparams.fill_parent, layoutparams.fill_parent)); - //Note that the ' Server name ' section of the URL, where ' 192.168.1.100 ' must be ' IP ' (although I was set to ' localhost ' when I published the map in Arccatalog. -Arcgisdynamicmapservicelayer MMAP =NewArcgisdynamicmapservicelayer ("Http://192.168.1.100:6080/arcgis/rest/services/china/MapServer"); - Mmapview.addlayer (MMAP); - Setcontentview (mmapview); in - //-----Manually added sections to } + - @Override the protected voidOnDestroy () { * Super. OnDestroy (); $ }Panax Notoginseng @Override - protected voidOnPause () { the Super. OnPause (); + mmapview.pause (); A } the @Override + protected voidOnresume () { - Super. Onresume (); $ mmapview.unpause (); $ } - -}
View Code
2, in addition, because my emulator memory is too small, so the additional need to configure the root directory of the ' Androidmanifest.xml ' file as (modify line 4th) ( Note the use of IP):
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Manifestxmlns:android= "Http://schemas.android.com/apk/res/android"3 Package= "Juk.demos"4 android:installlocation= "Auto"--Add this line5 Android:versioncode= "1"6 Android:versionname= "1.0">7 <USES-SDKandroid:minsdkversion= "+" />8 9 Ten <uses-permissionAndroid:name= "Android.permission.INTERNET" /> One <uses-permissionAndroid:name= "Android.permission.ACCESS_FINE_LOCATION" /> A <uses-permissionAndroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE" /> - <uses-featureandroid:glesversion= "0x00020000"android:required= "true"/> - the - <ApplicationAndroid:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"> - <ActivityAndroid:name=". Tryofflineactivity " - Android:label= "@string/app_name"> + <Intent-filter> - <ActionAndroid:name= "Android.intent.action.MAIN" /> + <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> A </Intent-filter> at </Activity> - - </Application> - </Manifest>
View Code
See my other blog specifically:Arcgis android-installation error:install_failed_insufficient_storage
3, the running result diagram is (over):
Create a new ArcGIS for Android project and display a local map