You are finishing Activity
when the Dialog
is showing.
This lines leads to finish your Activity
return super.onKeyDown(keyCode, event);
At that time You are displaying Dialog
which leads to leak your Dialog
window.
Change this line
return super.onKeyDown(keyCode, event);
into
return false;
otherise overeride onBackpressed()
and write this logic..