What is this error, and why does it happen?
05-17 18:24:57.069: ERROR/WindowManager(18850): Activity com.mypkg.myP has leaked window com.android.internal.pol
Best solution is just add dialog in try catch and dismiss dialog when exception occur
Just use below code
try { dialog.show(); } catch (Exception e) { dialog.dismiss(); }