Skip to content

Instantly share code, notes, and snippets.

@zeuxisoo
Created June 5, 2011 13:48
Show Gist options
  • Select an option

  • Save zeuxisoo/1008975 to your computer and use it in GitHub Desktop.

Select an option

Save zeuxisoo/1008975 to your computer and use it in GitHub Desktop.
[Android] Disable Home Button

In Activity (Android 2.0 UP)

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_HOME) {
		Log.i("TAG", "Press Home");
		System.exit(0);
		return true;
	} else {
		return super.onKeyDown(keyCode, event);
	}
}

@Override
public void onAttachedToWindow() {
	this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
	super.onAttachedToWindow();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment