如何处理这个由终结器抛出的“E/System未捕获异常”

时间:2022-01-31 20:28:51
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)

I got this problem,and I can't find what caused it.Colud anybody help me,thanks

我有这个问题,我找不出是什么引起的。主要有人帮我,谢谢

1 个解决方案

#1


1  

This would most likely occur if a thread didn't catch an exception.

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

From the stack trace, I'd assume you're making a thread? Inside the run method, wrap everything inside a try block. Then log all Exception's.

从堆栈跟踪中,我假设你在做一个线程?在run方法中,将所有内容封装在try块中。然后记录所有异常的。

Example

例子

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());
        }
    }
}

#1


1  

This would most likely occur if a thread didn't catch an exception.

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

From the stack trace, I'd assume you're making a thread? Inside the run method, wrap everything inside a try block. Then log all Exception's.

从堆栈跟踪中,我假设你在做一个线程?在run方法中,将所有内容封装在try块中。然后记录所有异常的。

Example

例子

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());
        }
    }
}