1231312312312
1231312312312
  • 发布:2019-08-27 17:23
  • 更新:2019-08-30 15:11
  • 阅读:935

如何捕获全局异常

分类:5+ SDK

自定义Application如下

public class BaseApplication extends DCloudApplication implements Thread.UncaughtExceptionHandler {  
    @Override  
    public void onCreate() {  
        super.onCreate();  
        Thread.setDefaultUncaughtExceptionHandler(this);  
    }  
    @Override  
    public void uncaughtException(Thread t, Throwable e) {  
       System.out.println("============"+e.getMessage())  
    }  
}

启动的Activity

public class H5Activity extends PandoraEntry{  
    
    @Override  
    protected void onCreate(Bundle bundle) {  
        super.onCreate(bundle);  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
    }  
  
    public void sendIntentDialog( String action, String msg ){  
        Intent intent = new Intent();  
        intent.setAction(action);  
        intent.putExtra(DialogReceiver.EXTRA_MSG, msg);  
        sendOrderedBroadcast(intent, null);  
    }  
}

js调用的方法

public class H5Utils {  
    public static int save( String strJson ){  
        int a = 0, b = 3;  
        // 抛出异常  
        System.out.println(b/a);  
    }  
}

执行js调用的方法save方法时会抛出异常,但是BaseApplicationuncaughtException方法不会执行,请问应该如何捕获全局异常信息?正确姿势是什么?

2019-08-27 17:23 负责人:DCloud_Android_ST 分享
已邀请:
1231312312312

1231312312312 (作者)

官方人员也没有解决方法?

该问题目前已经被锁定, 无法添加新回复