Go to android Study Notes ------------ block the return key, home key, and other entity keys

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.