0

i have tried different approaches to disable hardware home button through key-guard and key-down. it didn't work, i want functionality like Go-locker app. when i press on home button activity didn't close. please give me any idea about it. Thanks in advance.

Nazima Kauser MMF
  • 1,575
  • 3
  • 13
  • 11
  • Post what you have tried. – Sree Apr 22 '15 at 11:00
  • http://stackoverflow.com/a/12568747/1393623 – Swayam Apr 22 '15 at 11:12
  • i have tried thid code @Override public void onAttachedToWindow(){ Log.i("TESTE", "onAttachedToWindow"); this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); } public boolean onKeyDown(int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_HOME) { Log.i("TESTE", "BOTAO HOME"); return true; } return super.onKeyDown(keyCode, event); } – Nazima Kauser MMF Apr 22 '15 at 11:14

2 Answers2

1

Write this Intent filter in manifest in tag of your activity

         <intent-filter >
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.HOME" />
            <category android:name="android.intent.category.DEFAULT" />

        </intent-filter>
Stopfan
  • 1,519
  • 14
  • 22
  • Add following code to your activity: @override public void onAttachedToWindow() { this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow(); } – Stopfan Apr 22 '15 at 11:29
  • sir its didn't work. please give me any other solution if u did it, can you share code with me because all the option is not working. – Nazima Kauser MMF Apr 22 '15 at 12:30
1

Because the security reason, if any app can disable Home button, and also disables back button (onbackpress()), power button (by on/off receiver), so the app will never be killed, and your phone just shows the app. I think Go-locker has customed their laucher, you can do it, but i think it is not easy.

Regards !

NamNH
  • 1,690
  • 15
  • 33