Android Tips tool found issue.

来源:互联网 发布:胜思网络 石器时代 编辑:程序博客网 时间:2024/05/22 00:55


This Handler class should be static or leaks might occur (com.borqs.appinstaller.AppMoveFragment.LoadAppHandler)



Issue: Ensures that Handler classes do not hold on to a reference to an outer class
Id: HandlerLeak


In Android, Handler classes should be static or leaks might occur. Messages enqueued on the application thread's MessageQueue also retain their target Handler. If the Handler is an inner class, its outer class will be retained as well. To avoid leaking the outer class, declare the Handler as a static nested class with a WeakReference to its outer class.


非静态内部类如果是Handler子类,最好声明为static的以防止外部类的泄漏。