Disable system home in android 4.0

Source: Internet
Author: User

Disable system home in android 4.0

2.2 disable the system home key.

Recently, the project has a requirement to disable all system keys, such as menu, home, and back. At the same time, you also want to click the response and view pop-up. That is, the UI part should be normal.

The back key is disabled by onKeyDown.

I personally think that the simplest writing method can be found:

Http://blog.csdn.net/yiding_he/article/details/38527813


The key here is to disable the system home key after 4.0.

After searching for the Internet for a long time, it is basically useless. Because it is said that due to system security reasons, the android system absorbed the event (home, menu) at the framework layer and did not distribute it to the application layer.

The Menu key can't be disabled for security reasons, this key is handled by the framework and is never delivered to applications.

Http://stackoverflow.com/questions/15459407/disable-home-button-in-android-4-0

Look, there is no way for the stack overflow of foreigners.

When I was close to disappointment, I randomly clicked github, ghost.

More importantly, this great god is even Chinese. Too good.


Here, I will not elaborate on how the great gods implement it. The secret is to create an OverlayDialog and set some parameters for it, such as FLAG_SHOW_WHEN_LOCKED and FLAG_NOT_TOUCH_MODAL.

If you want to study, please download the source code.

Here we will only talk about the usage:

1. To the https://github.com/shaobin0604/Android-HomeKey-Locker, download the code of the great god.

2. Put HomeKeyLocker. java in HomeLockLib under your Util package.

3. Copy the OverlayDialog related part of styles in HomeLockLib to your styles.

4. Add it to your own AndroidManifest

5. The new HomeKeyLocker object is located at the place where you want to lock the key.

private HomeKeyLocker mHomeKeyLocker;mHomeKeyLocker = new HomeKeyLocker();


Use the lock key later:

MHomeKeyLocker. lock (mActivity. this );

Unlock:

MHomeKeyLocker. unlock ();

6. Add the following to your destroy method:

@Overrideprotected void onDestroy() {super.onDestroy();mHomeKeyLocker.unlock();mHomeKeyLocker = null;}


In this way, you can have fun.



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.