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
Window leaked exceptions have two reasons:
1) showing the dialog when Activity Context doesn't exists, to solve this you should show the dialog only you are sure Activity exists:
if(getActivity()!= null && !getActivity().isFinishing()){
Dialog.show();
}
2) not dismiss the dialog appropriately, to solve use this code:
@Override
public void onDestroy(){
super.onDestroy();
if ( Dialog!=null && Dialog.isShowing() ){
Dialog.dismiss();
}
}