1

I am making a custom lock app and for that i need to disable the home button and notification bar so that the messages cannot be read/ apps cannot be accessed from the notification bar before the phone is unlocked.

I have disabled the home button using the following code:

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

            if((keyCode == KeyEvent.KEYCODE_HOME)){

                  return true;
            }
            return false;
      }

      public void onAttachedToWindow()// to disable Home button 
      {
          // TODO Auto-generated method stub
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG|WindowManager.LayoutParams.FLAG_FULLSCREEN);

          super.onAttachedToWindow();
    }
Hartok
  • 2,147
  • 20
  • 37
vipin
  • 41
  • 9
  • You will not be able to disable home button in android ICS and above ..Google does not allow home button disabling in the ics and above.I was myself creating a custom locker and had to drop the idea because of this issue I faced in ics and other versions.There no way to disable home button in these versions! – Rachita Nanda Mar 01 '13 at 06:22
  • but is it possible to disable both the home button and notification bar in 2.2 and above? – vipin Mar 02 '13 at 08:39
  • yes you can disable home button below ics . – Rachita Nanda Mar 02 '13 at 09:17
  • both the home button and notification bar?? – vipin Mar 04 '13 at 14:16

2 Answers2

1

try this to disable to notification bar

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
ElefantPhace
  • 3,806
  • 3
  • 20
  • 36
  • this seems to work on the emulator but does disable the notification bar when the app is used on the phone – vipin Mar 01 '13 at 05:06
  • try commenting out your onAttachedToWindow override and see if that helps – ElefantPhace Mar 01 '13 at 05:16
  • ok, try just removing this then from setType `|WindowManager.LayoutParams.FLAG_FULLSCREEN` – ElefantPhace Mar 01 '13 at 05:39
  • still doesnt work.. all these work only when home key is enabled.. what i want to do is disable both the home key and the notification bar simultaneously – vipin Mar 01 '13 at 05:54
1

For your reference please look at Disable Home Button. And for hiding notification bar in android, you can use in your AndroidManifest.xml

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Community
  • 1
  • 1
βhargavḯ
  • 9,786
  • 1
  • 37
  • 59