zoukankan      html  css  js  c++  java
  • 使用Android Studio与ArcGIS Android SDK的开发环境部署和HelloWorld

    android studio(以下简称AS)是google推荐的android专用IDE,替代目前主流的eclipse,另外arcgis也把AS作为推荐的android IDE

    本文不介绍android SDK的部署和AS的安装

    以下网站应该是AS的官方中国官网,有很多AS相关基础教程和AS的下载(不用翻墙下载了),强烈推荐

    http://www.android-studio.org/

    本文代码以arcgis android SDK中的arcgis-android-sdk-v10.2.4samplesMapsHelloWorld为基础

    环境:Android SDK API 19,android studio 1.0,arcgis android SDK 10.2.4,小米4+MIUI v6


    首先new一个project,一直next就行

    新建project后,把这里切换到project


    打开以下文件

    把代码改为

     1 package jls.as7;
     2 
     3 import android.app.Activity;
     4 import android.os.Bundle;
     5 import android.view.Menu;
     6 import android.view.MenuItem;
     7 
     8 import com.esri.android.map.MapView;
     9 
    10 
    11 public class MainActivity extends Activity {
    12     MapView mMapView;
    13 
    14     @Override
    15     protected void onCreate(Bundle savedInstanceState) {
    16         super.onCreate(savedInstanceState);
    17         setContentView(R.layout.activity_main);
    18 
    19         // After the content of this Activity is set, the map can be accessed programmatically from the layout.
    20         mMapView = (MapView) findViewById(R.id.map);
    21     }
    22 
    23     @Override
    24     protected void onPause() {
    25         super.onPause();
    26 
    27         // Call MapView.pause to suspend map rendering while the activity is paused, which can save battery usage.
    28         if (mMapView != null)
    29         {
    30             mMapView.pause();
    31         }
    32     }
    33 
    34     @Override
    35     protected void onResume() {
    36         super.onResume();
    37 
    38         // Call MapView.unpause to resume map rendering when the activity returns to the foreground.
    39         if (mMapView != null)
    40         {
    41             mMapView.unpause();
    42         }
    43     }
    44 }

    打开arcgis android SDK的压缩包,在libs目录下,找到如下几个jar包

    复制到代码里如下目录


    同样是arcgis SDK的libs目录下,把以下几个文件夹

    复制到代码的如下目录(jniLibs目录默认不存在,要手动新建)


    打开AndroidManifest.xml,在manifest节点下,添加如下内容

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

    <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />


    打开moudle的build.gradle,在android节点下添加如下代码

    packagingOptions {
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
    }


    到此配置完毕,插上手机,Run运行程序

  • 相关阅读:
    自己定义九宫格手势解锁
    2015程序猴的总结:不破楼兰终不还!
    Codeforces Round #402 (Div. 2)
    [整体二分]【学习笔记】【更新中】
    BZOJ 3110: [Zjoi2013]K大数查询 [整体二分]
    BZOJ 2738: 矩阵乘法 [整体二分]
    BZOJ 2527: [Poi2011]Meteors [整体二分]
    [偏序关系与CDQ分治]【学习笔记】
    BZOJ 2244: [SDOI2011]拦截导弹 [CDQ分治 树状数组]
    COGS 2479. [HZOI 2016]偏序 [CDQ分治套CDQ分治 四维偏序]
  • 原文地址:https://www.cnblogs.com/cannel/p/4302232.html
Copyright © 2011-2022 走看看