How can I disable Android 4.0 home button?

风格不统一 提交于 2019-12-17 19:57:13

问题


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); 
}

回答1:


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!!




回答2:


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"/>


来源:https://stackoverflow.com/questions/11394843/how-can-i-disable-android-4-0-home-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!