How to disable home button in Android like lock screen apps do?

后端 未结 6 1760
后悔当初
后悔当初 2020-12-24 14:43

I know this question is asked many times but I found that none of the solution is working. I tried the code given below...

   protected void onPause() {
            


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 14:56

    Simple answer to your question is you cannot do that.

    The solution that you have mention was suggested by me about four years ago [Link].

    onUserLeavesHint, onKeyDown and onKeyDispatch will never "disable" hardware keys.

    If you really want to "handle" the Home button you will have to make your application as home screen. See this and this.

    If you really want to disable your hardware key without making a home screen application, you should root your device and the delete the corresponding device file from the kernel module. (Try at your own risk!)

提交回复
热议问题