[android學習]ArcGIS for Android

2012.11.12 10:30

ArcGIS Runtime SDK for Android v2.0安裝

一般的,eclipse安裝插件都是使用Help >> Install New Software安裝,arcgis當然也不例外,只是今天安裝的時候遇到了問題,無法在線安裝,找不到content.xml。

無妨,還有離線麼。可以到http://resources.arcgis.com/node/agreement/android-sdk下載,需要賬號,最新的版本號是2.0,zip壓縮包12M。不想到官網下的也可以戳這裏http://download.csdn.net/detail/seraph021724/4758368

個人覺得eclipse的插件安裝真的好方便大笑 


創建helloword

創建第一個arcgis android程序,可以使用file->new->Arcgis for Android。

我使用原來已有的程序talk,首先添加jar包,properties->java build path->libraries->add library。


arcgis android其實和js差不多,第一步就是要在layout裏添加一個容器用於顯示地圖,在這裏是mapview

<!-- MapView layout and initial extent -->
    <com.esri.android.map.MapView
  		android:id="@+id/map"
  		android:layout_width="fill_parent"
  		android:layout_height="fill_parent"
  		initExtent = "-19332033.11, -3516.27, -1720941.80, 11737211.28">
  	</com.esri.android.map.MapView>

在java文件里加載地圖,地圖就使用arcgisonline的地圖

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        
     // Retrieve the map and initial extent from XML layout
     		map = (MapView)findViewById(R.id.map);
     		// Add tiled layer to MapView
     		tileLayer = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
     		map.addLayer(tileLayer);
        
        Log.v(TAG, "begin");
        Button btnSubmit=(Button) findViewById(R.id.exit);
        btnSubmit.setOnClickListener(new OnClickListener(){

			public void onClick(View v) {
				// TODO Auto-generated method stub
                finish();//關閉當前Activity  
			}
        	
        });
    }


20121113   21:20

AVD不能調試arcgis for android程序

上面的程序如果直接在模擬器下運行果斷報錯,java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jincheng.talk/com.jincheng.talk.MapActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.esri.android.map.MapView。

原因似乎是因爲arcgis for android使用了openGL ES。不能調試的情況根據道聽途說有兩種,一種是arcgis for android 1.0.1後不能用模擬器調試,還一種是android4.0.3前不能用模擬器調試。不過我使用的android版本是最新,所以,也有可能是兩種情況兼而有之?我就不知道了-  -


如果使用真機調試

使用真機調試的重點是手機 驅動的安裝,我的三星的驅動裝了卸卸了裝,kies也是裝了卸卸了裝,就好像女生卸妝上妝,最後不知道腫麼滴就好了,應該還是跟kies有關,因爲是kies安裝好後重起計算機後自動安裝上了驅動,這時可以在CMD中使用adb devices命令看一下情況。

在真機調試時手機的開發->USB調試打勾,並保證手機內存足夠,腫麼在SDCARD中調試我目前還不知道,或者是要將程序安裝進SDCARD?

在<application>標籤中加入android:debuggable=”true”

最後,Run As–>Run Configuractions–>Target–>Deployment Target Selection Mode–>選中Launch on all compatible devices/AVD'S 下拉選擇 active devices。

這個時候再運行就肯定是在手機上運行了,而且可以成功RUN起來 ,但也還是有可能報錯call to OpenGL ES API with no current context (logged once per thread)這個錯誤似乎不影響地圖,具體神馬原因暫時未知-  -

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章