高德地图E/libEGL: call to OpenGL ES API with no current context (logged once per thread)

本文介绍了一种避免在使用高德地图MapView时出现闪退的方法。通过将mapView.onDestroy()方法放置在deactivate()中而非onDestroy()等生命周期方法中,可以有效避免E/libEGL:calltoOpenGLESAPIwithnocurrentcontext(loggedonceperthread)错误的发生。

高德地图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)。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值