自定义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
方法时会抛出异常,但是BaseApplication
中uncaughtException
方法不会执行,请问应该如何捕获全局异常信息?正确姿势是什么?
1 个回复
1231312312312 (作者)
官方人员也没有解决方法?