0

I can disable home button for Android 2.2, 3.0 etc. But same code does not work for 4.0. Is there any solution to disable home button?

@Override 
public void onAttachedToWindow() 
{ 
    super.onAttachedToWindow(); 
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); 
}
Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
Sean
  • 30
  • 1
  • 4
  • 3
    Not recommended to disable home button. But if anyone are to help you, you should first show the code that doesn't work for 4.0 – Warpzit Jul 09 '12 at 12:19
  • @Override public void onAttachedToWindow() { super.onAttachedToWindow(); this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); } – Sean Jul 09 '12 at 12:23
  • @Trakyali, Comments like that are unreadable, you should delete your comment and edit your question adding this code. – Egor Jul 09 '12 at 12:24

2 Answers2

5

Disabling the Home Button, many developers ask about such a feature!! but all I can say: you should absolutely not be disabling the home button in an Android application. This is a major anti-pattern, and will both make your app labelled as spammy and malware-like. Users hate when you disable their home button, and you should really avoid it at all costs. It's not against the law to do this , but your users will get pissed off and you will get a low ratings on google play for your app. Also This technique no longer works in Android 4.0, for obvious security reasons!!

K_Anas
  • 31,226
  • 9
  • 68
  • 81
3

u can simply add following code to ur android manifest:

   <action android:name="android.intent.action.MAIN" />              
   <category android:name="android.intent.category.HOME" />                 
   <category android:name="android.intent.category.DEFAULT" />               
    <category android:name="android.intent.category.MONKEY"/>
Akshay Gawde
  • 183
  • 1
  • 2
  • 9