I want create progressdialog in fragment but keep showing error is has leaked window com.android.internal.policy.impl.phonewindow that was originally added here. please help and this my code
private class ListDaftarHargaAsync extends AsyncTask<String, Void, String> {
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(getActivity());
progressDialog.setMessage("retrieving...");
progressDialog.setIndeterminate(false);
progressDialog.setCancelable(false);
}
@Override
protected String doInBackground(String... params) {
try {
modelPost.setDataVouchers();
} catch (JSONException e) {
e.printStackTrace();
}
String result = modelPost.resultString;
if (result.length() != 0) {
progressDialog.dismiss();
}
return null;
}
@Override
protected void onPostExecute(String result) {
progressDialog.dismiss();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
fillDaftarHarga();
}
});
}
}
Above error showing because you are calling
progressDialog.dismiss();
ondoInBackground
.