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
The "Activity has leaked window that was originally added..." error occurs when you try show an alert after the Activity is effectively finished.
You have two options AFAIK:
dismiss() on the dialog before actually exiting your activity.dialog in a different thread and run it on that thread (independent of the current activity).