Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6624819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:41:58+00:00 2026-05-25T21:41:58+00:00

I know, I know, this is a thing that I shouldn’t be doing… but

  • 0

I know, I know, this is a thing that I shouldn’t be doing… but I do it anyway as my app is for toddler and I need to block access to home key.

As I found here on SO, to block the home button I simply need to do:

@Override
public void onAttachedToWindow()
{
    super.onAttachedToWindow();
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);   
}

The main drawback of this is that the status bar is visible, even in in manifest file I’ve set it to be full screen

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

One solution would be to set full screen mode in code, so I do

@Override
     public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

So far so good, the app keeps running in full screen. One major problem tho, if the user presses Power button the phone enters in standby. When press again and unlock the screen, the application has the status bar visible again. I can’t set window parameters again as it already has content. Also, I am thinking to disable the Power button but I don’t know how. I can intercept it being pressed onKeyDown but how should I make it not do anything ?

@Override
        public boolean onKeyDown(int keyCode, KeyEvent event)  {

           switch (keyCode) {

                case KeyEvent.KEYCODE_POWER:
                    ????????

                default:
                    return false;
                }
        }

Any ideas on those matters ? Thank you all.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:41:58+00:00Added an answer on May 25, 2026 at 9:41 pm

    Actually, after doing a little bit of deep testing it seems that setting

    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); 
    

    produces unwanted behavior like: no Toast messages, unresponsive application, as said before, not allowing fullscreen app. So I just decided to keep Home button as it is by default, enabled. It would have been really nice from Google to offer possibility to disable the button… even if they would have need to make a special permission for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i didn't really know how to title this question, but here's a thing that
I like vectors a lot. They're nifty and fast. But I know this thing
Please forgive my programming knowledge. I know this is a simple thing, but I
I know there is no such thing as a dumb question but this is:
I know that there is already a question (actually some more) about this, but
I want to know what does RETURN_VALUE mean! I'm stuck at this thing. How
the only thing i know about this subject is... in PHP 5, when a
I don't know if this is a well known 'thing' or something new in
I don't think this is technically a macro but I don't know what else
I know this has been asked a few times but please bear with me.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.