title: Memory leak with ProgressDialog in android Application class
body: <p>I use a progress Dialog in my Application class with Lottie, but there is a memory leak when progress Dialog is showing. How can I fix it?</p>
  
  <p>My Application Code is:</p>
  
  <pre><code>public class AppController extends Application {
  public static final String TAG = AppController.class.getSimpleName();
  private static AppController mInstance;
  AppCompatDialog progressDialog;
  
  @Override
  public void onCreate() {
      super.onCreate();
      if (LeakCanary.isInAnalyzerProcess(this)) {
          // This process is dedicated to LeakCanary for heap analysis.
          // You should not init your app in this process.
          return;
      }
      LeakCanary.install(this);
      // Normal app init code...
  
      mInstance = this;
  }
  
  public static synchronized AppController getInstance() {
      return mInstance;
  }
  
  /**
   * Progress Dialog
   */
  public void progressON(Activity activity) {
      if (activity == null) {
          return;
      }
      if (progressDialog != null &amp;&amp; progressDialog.isShowing()) {
      } else {
          progressDialog = new AppCompatDialog(activity);
          progressDialog.setCancelable(false);
          progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
          progressDialog.setContentView(R.layout.progress_loading);
          progressDialog.show();
      }
  
      final LottieAnimationView lottieAnimationView = (LottieAnimationView) progressDialog.findViewById(R.id.progress_lottie);
      lottieAnimationView.playAnimation();
  
  }
  
  public void progressOFF() {
      if (progressDialog != null &amp;&amp; progressDialog.isShowing()) {
          progressDialog.dismiss();
      }
  }
  }
  </code></pre>
  
  <p>and when I am using progress on/off:</p>
  
  <pre><code>AppController.getInstance().progressON(PartnerDetailActivity.this);
  AppController.getInstance().progressOFF();
  </code></pre>
  
  <p>Error image is:
  <a href="https://i.stack.imgur.com/ia0MB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ia0MB.jpg" alt="memory leak image"></a></p>