title: Does making the handler (of the main UI fragment) publicly accessible have any complications?
body: <p>I need to create a UI fragment that can be updated by many background threads. Does making the handler publicly accessible in the way shown below, have any complications? I have not come across anyone doing this and so I am a bit worried.</p>
  
  <pre><code>public class MainFragment extends Fragment {
  
  private static class MyHandler extends Handler {
      WeakReference&lt;MainFragment&gt; mFrag;
  
      MyHandler(MainFragment aFragment) {
          mFrag = new WeakReference&lt;MainFragment&gt;(aFragment);
      }
  
      @Override
      public void handleMessage(Message message) {
          // Unpack message and handle specific UI updates
          // calling MainFragment's methods using the
          // weak reference 'mFrag'
      }
  }
  
  private static MyHandler mHandler;
  
  // Create handler on resume
  @Override
  public void onResume() {
      super.onResume();
      mHandler = new MyHandler(this);
  }
  
  @Override
  // Destroy handler on pause
  public void onPause() {
      super.onPause();
      mHandler = null;
  }
  
  // When a background thread wants to update the main
  // UI, it calls this method as
  // MainFragment.getHandler().post(message)
  public static Handler getHandler() {
      return mHandler;
  }
  </code></pre>
  
  <p>}</p>