Preventing the HOME button to close activity
===

I am currently using a custom AlertDialog which has a Theme.Dialog theme in a Activity that requires users to type the current password to proceed.

According to http://stackoverflow.com/questions/2162182/android-is-it-possible-to-disable-the-click-of-home-button i have tried most of the methods but it doesn't work.

The only one that worked was:

    @override
    
    public void onAttachedToWindow()
    {  
           this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
           super.onAttachedToWindow();  
    }

But it was screwing up with a couple of my lines that actually require me to relaunch the activity if the password was wrong.