高德地图mapView退出界面时,会出现如下错误:
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
这个问题在activity和fragment中都会出现。这个问题在手机中,经常表现为闪退。
验证发现:mapview.onDestroy 只有放在deactivate中才不会出现。 而放在onDestroy, onDestroyView,onStop中都会出现。
参考如下实例:
@Override
public void onStop() {
AppData.com_mqttHandle_command(Constants.HANDLE_REALT_STATUS_OFF);
super.onStop();
if (mLocationClient != null) {
mLocationClient.stopLocation();
mLocationClient.onDestroy();
}
mLocationClient = null;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void deactivate() {
mMapView.onDestroy();
}
采用这种方式,在activity和fragment中,都不会出现E/libEGL: call to OpenGL ES API with no current context (logged once per thread)。
本文介绍了一种避免在使用高德地图MapView时出现闪退的方法。通过将mapView.onDestroy()方法放置在deactivate()中而非onDestroy()等生命周期方法中,可以有效避免E/libEGL:calltoOpenGLESAPIwithnocurrentcontext(loggedonceperthread)错误的发生。
1921

被折叠的 条评论
为什么被折叠?



