图层损坏 E/ArcGIS﹕ The map or layer has been destroyed or recycled. 资源未释放

看到论坛上有个网友和我一样的问题:

The map or layer has been destroyed or recyled

 

teamigal

Hello,

I have a problem when the app restores after the map activity has been destroyed by the system.
The system calles OnDestroy on it's own, which is fine, but then, when i open the app back, everything restores (the app calles OnCreate again) except for the mapView Object.
When i try to add layers to the mapView i get the following message:

"The map or layer has been destroyed or recyled"

Does anybody had the same problem?
Any clues how to fix this?

-------------------------------------------------------------------------------------------------------

 

我这边的详细问题是:

地图的Activity onDestroy()后,在重新打开app的时候就报 The map or layer has been destroyed or recycled.错误,然后地图能显示

但是数据丢了..


原来的destroy()

@Override
	protected void onDestroy() {
		featureLayers.clear();
		mMapView.destroyDrawingCache();
		try {
			unregisterReceiver(receiver);
		}
		catch (Exception e){
			e.printStackTrace();
		}
		try {
			unregisterReceiver(receiver2);
		}
		catch (Exception e){
			e.printStackTrace();
		}
		//结束服务,如果想让服务一直运行就注销此句
		try {
			stopService(new Intent(this, LocationService.class));
		}
		catch (Exception e){
			e.printStackTrace();
		}
		super.onDestroy();

	}



//初始化数据图层
	private void initializeRoutingAndGeocoding() {
				for(int i=0;i<allfloor;i++) {
					Geodatabase geodatabase = null;
					try {
						geodatabase = new Geodatabase(geofilename[i]);
						List<GeodatabaseFeatureTable> table = geodatabase.getGeodatabaseTables();
						Log.i("zjx", "list:" + table);

						GeodatabaseFeatureTable mytable;
						if(i==1)mytable = geodatabase.getGeodatabaseFeatureTableByLayerId(0);
						else mytable= geodatabase.getGeodatabaseFeatureTableByLayerId(1);

						Log.i("zjx","mytable:"+mytable);
						featureLayers.add(new FeatureLayer(mytable));  //问题出在这
						// Attempt to load the local geocoding and routing data
						mMapView.addLayer(featureLayers.get(i));      //之前的资源没有释放(list.clear()),get(i)并不是新增的
					} catch (FileNotFoundException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				trygetDataName();
	}

所以在onDestroy 里面加一下释放所有资源的函数,以前一直以为java会自己快速回收的= =

esri论坛sso不能登录,希望那个外国网友能看到这文章把~

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

posted on 2015-08-02 11:05 france 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/france/p/4808543.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值