ANR和FC

ANR(Activity Not Respone)即无响应

  限制:Main线程即为UI线程,不建议耗时事件(超过五秒)当用户输入事件5s内没有得到响应,将弹出ANR对话框

    解决方法  让所有可能的耗时操作都要在子线程()中执行(常见耗时操作:I/O:网络操作SDcard 数据运算

FC(Force close)

 出现该异常原因:1.Error OOM(out of memory error) StackOverFlowError  2.RuntimeException

  其中子线程不能更新UI的解决方法:

1、 将子线程执行结果发送到Main线程:handler+massage线程间通讯

2、 使更新ui代码段在Main线程执行:

        1.runOnUiThread    2.view.post view.postDelay()   3.handler.post handler.postDelay()

       

       

原文地址:https://www.cnblogs.com/feary/p/5382588.html