Reputation: 375
I hava a problem with a ProgressDialog in my App. I'm doing some tasks in background and notify actions to my Activity using a Handler. Sometimes, not always, when I try to show my Dialog app crashes and appears this exception:
android.view.windowleaked
The way of dialog is launched:
try {
pd = new ProgressDialog(VoiceAcquisitionActivity.this);
pd.setMessage("blablabla");
pd.setCancelable(false);
pd.show();
} catch (Exception e) {
e.printStackTrace();
}
I've read and this exception is normal in .dismiss()
operation but in .show()
??
How can I avoid this problem?
Thanks
Upvotes: 0
Views: 410
Reputation: 13922
for safety you could wrap your dialog logic in a block of code like:
if(!isFinishing()){
pd = newProgressDialog(VoiceAcquisitionActivity.this);
pd.setMessage("Loading message");
pd.setCancelable(false);
pd.show();
}
Upvotes: 1