title: Handlers and memory leaks in Android
body: <p>Please have a look at the code below:</p>
  <pre><code>public class MyGridFragment extends Fragment{
      
      Handler myhandler = new Handler() {
          @Override
          public void handleMessage(Message message) {
              switch (message.what) {
                  case 2:   
                      ArrayList&lt;HashMap&lt;String,String&gt;&gt; theurls = (ArrayList&lt;HashMap&lt;String,String&gt;&gt;) message.obj;
                      urls.addAll(theurls);
                      theimageAdapter.notifyDataSetChanged();
                      dismissBusyDialog();
                      break;
              }
          }
      }
  }
  </code></pre>
  <p>When I use handler like this I get a warning &quot;handler should be static, else it is prone to memory leaks.&quot; Can someone tell me what is the best way to do this?</p>