Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From <a href="http://tools.android.com/tips/lint-checks" rel="nofollow">Android lint checks</a>:</p> <pre> HandlerLeak ----------- Summary: Ensures that Handler classes do not hold on to a reference to an outer class Priority: 4 / 10 Severity: Warning Category: Performance 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. </pre> <p>First part of the warning is because <code>final Handler handler = new Handler()</code> creates an anonymous inner class. Inner classes can't be created in a standalone fashion, you always need an outer instance. Remember how you would create this in Java <code>OuterClass.InnerClass innerObject = outerObject.new InnerClass();</code>. Every inner class object also has to keep a reference to outer object <code>Outer.this</code> to access outer's members.</p> <p>Second part is <code>final Message message = handler.obtainMessage( 1, MyFunction( context));</code> has a handle to your inner handler class (which has a handler to outer Activity class). If this message lives long enough, it won't be possible to garbage collect your Activity.</p> <p>What can block your message being processed? Unfortunately lint tool can't figure that out, so it always warns you about possible memory leak. If you are sure about what you are doing, you can suppress these messages by <a href="http://tools.android.com/recent/ignoringlintwarnings" rel="nofollow">various methods</a>.</p> <p>For your case it doesn't look like a good idea to make <code>Activity</code> a <code>Runnable</code> but anyway may be you should use <a href="http://developer.android.com/reference/android/os/Handler.html#post%28java.lang.Runnable%29" rel="nofollow">Handler.post</a> or best <a href="http://developer.android.com/reference/android/app/Activity.html#runOnUiThread%28java.lang.Runnable%29" rel="nofollow">Activity.runOnUIThread</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload