各位大佬,我在点击返回按钮关闭页面释放资源时,程序崩溃,释放资源的代码如下:
if (mMapControl!!.map != null) {
mMapControl!!.map.close()//从MapControl中获取的map对象仅需要关闭即可,无需dispose
}
if (mMapControl != null) mMapControl!!.dispose()
mMapControl=null;
if (mWorkspace != null) {// mWorkspace!!.close();和 mWorkspace!!.dispose()第二次打开页面时,程序会崩溃(关闭页面等待几秒即可重新打开)
mWorkspace!!.close();
mWorkspace!!.dispose()
mWorkspace=null;
}
崩溃信息:
E/: [qarth_debug:] get PatchStore::createDisableExceptionQarthFile method fail.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xtkj.test PID: 14017
java.lang.IllegalStateException: getMap()
at com.supermap.mapping.MapControl2.getMap(MapControl2.java:1227)
at com.supermap.mapping.MapControl.getMap(MapControl.java:496)
at com.supermap.mapping.MapView.b(MapView.java:398)
at com.supermap.mapping.MapView.a(MapView.java:189)
at com.supermap.mapping.MapView.onLayout(MapView.java:170)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1842)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1686)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1595)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1842)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1686)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1595)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1842)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1686)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1595)
at android.view.View.layout(View.java:20948)
at android.view.ViewGroup.layout(ViewGroup.java:6279)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at com.android.internal.policy.DecorView.onLayout(DecorView.java:9
I/System.out: 崩溃:getMap()
请问我该如何解决这个问题?
另外,我试着在释放资源的时候不释放mapcontroll,程序不会崩溃,但是如果在释放资源的时候释放了工作空间的资源,关闭页面,在打开地图页面(间隔时间很短),程序也会崩溃。