zoukankan      html  css  js  c++  java
  • 移动端 异常捕获

    1.自定义类实现  UncaughtExceptionHandler ,重写 uncaughtException。

    import java.lang.Thread.UncaughtExceptionHandler;

    public class myCustomExceptionHandler implements UncaughtExceptionHandler{

    private UncaughtExceptionHandler defaultUEH;

    public myCustomExceptionHandler() {

    this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
    // TODO Auto-generated method stub

    System.out.println("应用程序异常");
    /**
    * 处理异常,保存异常log或向服务器发送异常报告
    */
    defaultUEH.uncaughtException(thread, ex);;
    }

    }

    2.在要调用的activity 中(onCreate)加入 

    Thread.setDefaultUncaughtExceptionHandler(new myCustomExceptionHandler());

  • 相关阅读:
    程序中图片透明 函数(使用SetBkColor API函数)
    编程中使用锁
    event内存泄漏
    diskcache
    linux内核管理
    Vue
    Paxos算法
    索引以及页和区
    CoreRT
    二叉树
  • 原文地址:https://www.cnblogs.com/Snowflake/p/3620694.html
Copyright © 2011-2022 走看看