How to disable home key

From wizarPOS

Disable home key in apk

  • Defines the following permission, the third-party app will get the event of home key or back key.
  • Catches the event when the home key or back key is pressed.

Permission

 android.permission.CLOUDPOS_DISABLE_HOME_KEY

The app declares the permission in manifest.

Monitor onKeyDown

 //Monitor physical keyboard
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_HOME) {
            Log.e("DEBUG", "KEYCODE_HOME");
//			android.os.Process.killProcess(android.os.Process.myPid());
            btn4_home.setBackgroundColor(Color.GREEN);
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            btn1_return.setBackgroundColor(Color.GREEN);
            Log.e(TAG, "KEYCODE_BACK");
            isSuccessReturn = true;
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            btn2_menu.setBackgroundColor(Color.GREEN);
            Log.e(TAG, "KEYCODE_MENU");
            isSuccessMenu = true;
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

Demo

Download demo