Disable hardware keys (home, back, ....) in android 4.4
I am writing a program for children, it has its own applications, folders and functions. so when kids want to play with their parent device, parents launch this launcher and they can be sure that their kids can't mess with their data. and to exit this launcher, parents need to enter their password. so when kids are using this launcher, Home button
and Back button
other hardware keys should not work as well, for example, if the function is Back button
working, the child can leave the launcher, and parents have to enter their password to exit this launcher.
any idea what how can i disable hardware keys
or any other way to handle it?
If you want to disable the Home, Menu and Back buttons. There is a way to find the key layout files found in out / target / product / generic / system / usr / keylayout. Open the Generic.kl file and comment below by adding#
# key 158 BACK WAKE_DROPPED
# key 172 HOME
Need further advice, I'm here to help :) Link to Disable android rom hardware keys
you have to override the onBackPressed method in your activity
@Override
public void onBackPressed () {
your code
super.onBackPressed();
...
}
for the home button it depends on what action you are using. take a look at: http://android-developers.blogspot.co.il/2014/10/appcompat-v21-material-design-for-pre.html