The blocking key can override the two methods of activiy.
Blocked return key
Public boolean onKeyDown (int keyCode, KeyEvent event ){
Switch (keyCode ){
Case KeyEvent. KEYCODE_BACK:
Return true;
}
Return super. onKeyDown (keyCode, event );
}
The shielded home key and other keys are different.
Public void onAttachedToWindow (){
This. getWindow (). setType (WindowManager. LayoutParams. TYPE_KEYGUARD );
Super. onAttachedToWindow ();
}
Shield other entity buttons
Switch (keyCode ){
Case KeyEvent. KEYCODE_HOME:
Return true;
Case KeyEvent. KEYCODE_BACK:
Return true;
Case KeyEvent. KEYCODE_CALL:
Return true;
Case KeyEvent. KEYCODE_SYM:
Return true;
Case KeyEvent. KEYCODE_VOLUME_DOWN:
Return true;
Case KeyEvent. KEYCODE_VOLUME_UP:
Return true;
Case KeyEvent. KEYCODE_STAR:
Return true;
}
The screen disappears after the home key is blocked. www.2cto.com indicates that you set full screen in the Code and go to AndroidManifest. xml to set full screen.
<Activity android: name = ". WelcomeActivity" android: label = "@ string/app_name"
Android: theme = "@ android: style/Theme. NoTitleBar. Fullscreen"
>
From running snails