Android 4.0 disables the system home key (continued) and android4.0
The last method was available in note3 and s5. However, some enthusiastic friends replied that the system home key could not be disabled on other mobile phones.
So I searched again and finally found this post:
Try to block the home Key and recentApp !! Http://c.tieba.baidu.com/p/3225440025? Pn = 2
There is a very simple method at the end of this post, which should be able to implement the functions we need. (It seems that Huawei's mobile phone is okay)
If you need to view the details of the post, please step: http://c.tieba.baidu.com/p/3225440025? Pn = 2
I will paste the relevant function code here:
public void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.d_main);View view = View.inflate(getApplicationContext(), R.layout.d_main, null);WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);WindowManager.LayoutParams params = new WindowManager.LayoutParams();params.type = 2003;params.width = -1;params.height = -1;wm.addView(view, params);}
Add related permission to manifest:
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/><uses-permission android:name="android.permission.STATUS_BAR"/><uses-permission android:name="android.permission.DISABLE_STATUS_BAR"/>
Let's have a try and see if you can play happily.
How to disable the HOME Key in android403?
The home key is a reserved key and cannot be controlled by the app.
How does android40 shield the home Key?
This can be blocked. I have been engaged in the development of the screen lock software for android phones. In version 2.2 and 2.3, override the following method to override the home key public void onAttachedToWindow () {this. getWindow (). setType (WindowManager. layoutParams. TYPE_KEYGUARD); super. onAttachedToWindow ();} but it cannot be used if it is above 4.0. I just found that there is another way to block and override the Home key on MySQL 4.0, which is very simple. The Code is as follows: public static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000; // you need to define the public void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); this. getWindow (). setFlags (FLAG_HOMEKEY_DISPATCHED, FLAG_HOMEKEY_DISPATCHED); // key code setContentView (R. layout. main);} Then rewrite the onKey event. @ Override public boolean onKeyDown (int keyCode, KeyEvent event) {// TODO Auto-generated method stub if (keyCode = event. KEYCODE_HOME) {return true;} return super. onKeyDown (keyCode, event );}