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的以防止外部类的泄漏。
本文讨论了Android中如何避免由于Handler类引用导致的内存泄漏问题。建议将非静态内部类声明为静态以防止外部类泄漏,并使用WeakReference来弱引用外部类。
710

被折叠的 条评论
为什么被折叠?



