How to disable Home button without using the TYPE_KEYGUARD?

后端 未结 7 1506
滥情空心
滥情空心 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:40

    Try this code :

    @Override
     public void onAttachedToWindow() {
      // TODO Auto-generated method stub
         super.onAttachedToWindow();  
    
         handler.postDelayed(mUpdateUiMsg, 100);
    
     }
    
    
     public boolean onKeyDown(int keyCode, KeyEvent event) {
      // TODO Auto-generated method stub
      if(keyCode==KeyEvent.KEYCODE_BACK){
       return true;
      }
      if(keyCode==KeyEvent.KEYCODE_HOME){
       return true;
      }
    
      return super.onKeyDown(keyCode, event);
     }
    
    
     private Runnable mUpdateUiMsg = new Runnable() {
            public void run() {
    
    
                getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    
    
             }
        };
    

提交回复
热议问题