For back button
you can Override
onBackPressed
method like below :-
@Override
public void onBackPressed() {
// do what you want
}
For Home Button
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
For Disable recent app
button : -
Step 1
Add this permission to the manifest.xml
file
<uses-permission android:name="android.permission.REORDER_TASKS" />
Step 2
Put this code in any Activity on which you want to block/disable the recent apps button
@Override
protected void onPause() {
super.onPause();
ActivityManager activityManager = (ActivityManager) getApplicationContext()
.getSystemService(Context.ACTIVITY_SERVICE);
activityManager.moveTaskToFront(getTaskId(), 0);
}