Look at these pieces of code:
Custom views and window attributes on Android
Problem
When I click \'Home button\', exception
exception
Leaked window usually happens when your context show dialogs and that context is suddenly forced close that your dialog has not been dismissed properly.
In order to fix this, you have to fix your errors before the window has leaked error.