Q:

Android 9.0 Activity has leaked window that was originally added

I just added android:usesCleartextTraffic="true" to support volley in android 9.0 but the progress dialog window gets leaked after loading is complete. 
NB> This problem is only in android 9. It works well in other android versions

A:

Please check below scenario :
onStop() method Activity cycle called when no longer activity visible there we can check either mDialog is null or not. If mDialog isn’t null that mean your activity leaked window so you can dismiss it onStop() method.
@Override
protected void onStop() {
   super.onStop();
   if(mDialog!=null){
     mDialog.dismiss;
   }
}

Hope this will help!

