I have an application. I tried to disable home button. Many people said that it doesn't possible to do in android 4.0 and above. So i decided to reload the same activity when press home button. I followed the below code.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyDown(keyCode, event);
if (keyCode == KeyEvent.KEYCODE_HOME) {
System.out.println("==============================");
Intent i = new Intent(getBaseContext().getPackageManager()
.getLaunchIntentForPackage(
getBaseContext().getPackageName()));
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
return true;
}
return false;
}
I can't get any response when press home button. Can you tell me what's my wrong?
This key cannot be intercepted, so KEYCODE_HOME
won't be send to you.