How to disable home and back buttons?
Asked
Active
Viewed 621 times
0
-
you can override onBackPressed in Activity to prevent closing activity. – AIMIN PAN Nov 01 '18 at 08:14
1 Answers
0
Home Button:
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
To disable Home Button:
@Override
public void onAttachedToWindow() {
// TODO Auto-generated method stub
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
To disable Back Button:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Do nothing or catch the keys you want to block
}
To add this in your Android Manifest:
<uses-permission android:name="android.permission.REORDER_TASKS" />

PartTimeNerd
- 305
- 1
- 2
- 20