禁用Android主页按钮

禁用Android主页按钮,android,android-studio,lockscreen,Android,Android Studio,Lockscreen,我正在实施锁屏应用程序,用户需要输入密码并解锁设备一段时间 我测试了三星Note 3和小米redmi 1 注3中的所有物理按钮都已锁定,但不知何故,我无法禁用小米红米1的主页按钮**主页按钮将在暂停事件时运行 我使用了无法在logcat中显示按钮的代码 @Override public boolean dispatchKeyEvent(KeyEvent event) { Log.d("button", String.valueOf(event.getKeyCode())

我正在实施锁屏应用程序,用户需要输入密码并解锁设备一段时间

我测试了三星Note 3和小米redmi 1

注3中的所有物理按钮都已锁定,但不知何故,我无法禁用小米红米1的主页按钮**主页按钮将在暂停事件时运行

我使用了无法在logcat中显示按钮的代码

@Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        Log.d("button", String.valueOf(event.getKeyCode()));
        return true;
    }
我尝试使用onPause并再次运行我的应用程序,但响应缓慢

@Override
public void onPause() {
    super.onPause();.
    Intent intent = new Intent(LockScreenActivity.this, SettingActivity.class);
    startActivity(intent);
}
change-laucher
修改AndroidManifest.xml
致:
--------------------------------------
更换laucher
修改AndroidManifest.xml
致:
--------------------------------------

我的应用程序中已经有代码,仍然无法禁用小米红米笔记本1中的home按钮,可能该按钮是特殊的…我的应用程序中已经有代码,仍然无法禁用小米红米笔记本1中的home按钮,可能该按钮是特殊的…可能重复检查此按钮可能重复检查此按钮
Try this overridden method

@Override
public void onAttachedToWindow() {
    this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
    super.onAttachedToWindow();
}


but it's not a good practice to disable home button.
change laucher
modify AndroidManifest.xml
        <intent-filter>  
             <action android:name="android.intent.action.MAIN" />  
             <category android:name="android.intent.category.LAUNCHER" />  
         </intent-filter>  

To:
--------------------------------------
       <intent-filter>  
        <action android:name="android.intent.action.MAIN" />  
        <category android:name="android.intent.category.HOME"/>  
        <category android:name="android.intent.category.DEFAULT" />  
        <category android:name="android.intent.category.MONKEY" />  
       </intent-filter>