Android: associate a method to home button of smartphone

前端 未结 3 691
无人共我
无人共我 2020-12-10 23:08

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 i

3条回答
  •  旧时难觅i
    2020-12-10 23:31

    Try overriding onKeyDown as such:

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_HOME)
            // do what you need
    }
    

提交回复
热议问题