How can I disable Android 4.0 home button?
Asked Answered
K

2

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); 
}
Kp answered 9/7, 2012 at 12:16 Comment(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.0Shaunta
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); }Kp
@Trakyali, Comments like that are unreadable, you should delete your comment and edit your question adding this code.Neoterize
R
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!!

Rewrite answered 9/7, 2012 at 12:27 Comment(3)
You are right but i want to make a launcher and i need this feature.Kp
@Trakyali You don't need to disable home button in order to make a launcher.Shaunta
How about customized android tablets used for public access? It's definitely a necessary feature.Demolition
A
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"/>
Advocation answered 30/1, 2013 at 10:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.