How to disable Home button without using the TYPE_KEYGUARD?

后端 未结 7 1557
滥情空心
滥情空心 2020-12-24 03:58

i create a lockscreen application and i need to disable a home button, so if that phone is stolen, that phone can\'t be accessed.. my lockscreen is a fullscreen activity.. i

7条回答
  •  情书的邮戳
    2020-12-24 04:34

    In my Samusung Pocket, nothing above worked fine. I could make it finally after further search.

    I put full screen them in your AndroidMainfest.xml like following (not in Acitivity code):

    
    

    And use keygurad onAttachedToWindow() method in your activity:

    @Override
    public void onAttachedToWindow() {
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
        lock.disableKeyguard();
    }
    

    Exactly what I have wanted. Blocking HOME button and same after turning off/on.

提交回复
热议问题