Arcgis地图Android崩溃提示 “EGL_BAD_CONFIG"

报错详情见https://www.bbsmax.com/A/x9J2DXZVd6/:

java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:)
at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:)
at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:)

测试发现,截止到最新arcgis版本100.5.0,在华为honor DUA-AL00(Android8.1.0)机型上依旧报这个错。
怎么办呢,只好捕获异常了。
解决方法如下:

package com.tepia.guangdong_module.amainguangdong.common;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.tepia.base.utils.LogUtil;
import com.tepia.base.utils.ToastUtils;
import com.tepia.base.utils.Utils;
import com.tepia.guangdong_module.amainguangdong.SplashOfGDActivity;


/**
 * @author  Liying
 * on 2017-3-8.
 */

public class CrashHandler implements Thread.UncaughtExceptionHandler {
    public static final String TAG = "CrashHandler";
    private static CrashHandler INSTANCE = new CrashHandler();
    private Context mContext;

    private CrashHandler() {
    }

    public static CrashHandler getInstance() {
        return INSTANCE;
    }

    public void init(Context context) {
        //避免
        mContext = context;
        Thread.setDefaultUncaughtExceptionHandler(this);
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        //throwEglException

        LogUtil.e(TAG, "some uncaughtException happend"+ex.getMessage());
        String mes = ex.getMessage();
        if (mes != null && mes.contains( "EGL_BAD_CONFIG")) {
            LogUtil.e(TAG, "该机型不支持Arcgis地图");

            ToastUtils.shortToast("该机型不支持Arcgis地图");
            new Thread() {
                @SuppressWarnings("WrongConstant")
                @Override
                public void run() {
                    ((Activity)mContext).finish();
                   /* Intent intent = new Intent(mContext, SplashOfGDActivity.class);
                    PendingIntent restartIntent = PendingIntent.getActivity(mContext, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
                    AlarmManager mgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
                    mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, restartIntent);
                    android.os.Process.killProcess(android.os.Process.myPid());*/
                }
            }.start();
        }else if(mes != null && mes.contains("EGL_SUCCESS")){
            ToastUtils.shortToast("EGL_SUCCESS报错");
            new Thread(){
                @Override
                public void run() {
                    ((Activity)mContext).finish();

                }
            }.start();
        }

    }
}

这样至少能保证不崩溃。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值