如何处理这个“电子/系统:终结者抛出的未捕获的异常”

时间:2014-05-27 00:42:51

标签: android

05-27 08:21:21.538  31650-31659/com.yiliantech.wifi E/System﹕ Uncaught exception thrown by finalizer
05-27 08:21:21.538  31650-31659/com.yiliantech.wifi E/System﹕ java.lang.NullPointerException
        at android.net.wifi.WifiManager.finalize(WifiManager.java:2134)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
        at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
        at java.lang.Thread.run(Thread.java:856)

我遇到了这个问题,我无法找到导致它的原因。可以有人帮助我,谢谢

1 个答案:

答案 0 :(得分:1)

如果线程没有捕获异常,则很可能发生这种情况。

从堆栈跟踪中,我假设你正在创建一个线程? 在run方法中,将所有内容包装在try块中。然后记录所有Exception

实施例

Thread myThread = new Thread(new MyRunnable());
myThread.start();

class MyRunnable extends Runnable
{
    @Override
    public void run()
    {
        try {
            // Your code, where the exception was thrown
        } catch (Exception ex) {
            // Here we are logging the exception to see why it happened.
            Log.e("my app", ex.toString());
        }
    }
}