how can I associate a method to home button of smartphone? I want that checking this botton my Android app does a specific method. I read that to disable home button there is the method:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
but it isn't useful for me. How can I solve this problem?
Use This Code For only HomeWtcher class this one is better.
Use this code:
HomeWatcher:
OnHomePressedListener:
Try overriding onKeyDown as such: