解决办法: public class SampleActivity extends Activity { /** * Instances of static inner classes do not hold an implicit * reference to their outer class. */ private static class MyHandler extends Handler { private final WeakReference<SampleActivity> mA…
此文属于转载! 最近用到handle在线程中改变UI,会跟给出“This Handler class should be static or leaks might occur”的警告,网上看了很多解决办法,但都不够详细,这里我重新写一下这个问题的解决办法. 1.问题原因:在ADT 20 Changes我们可以找到这样一个变化:“New Lint Checks: Look for handler leaks: This check makes sure that a handler inner…
更新到adt2.0的开发者们可能会在handler上发现这么一条警告:This Handler class should be static or leaks might occur . 首先在ADT 20 Changes我们可以找到这样一个变化:New Lint Checks: Look for handler leaks: This check makes sure that a handler inner class does not hold an implicit reference …