I wanted to call certain function for showing notifications on pressing of homebuttonclick event.
I refered this blog.
Written code as:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
if(keyCode == KeyEvent.KEYCODE_HOME){
APP_STATUS="SLEEP";
LocalToNotification();
}
return true;
}
But unfortunatly it was not working.
I tested through debugger, but observed that debugger is also not comming on this line of code upon pressing home button.
What is wrong in above code?
Please help me.
On older Android version this is working. But Android changed this, because they say "Home Button should stay Home Button" and they don't want that anybody override the Home Button. And because of this reason your code is not working anymore.
If you want to do something when the home button is pressed, then do this in the onPause method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With