Detect soft navigation bar availability in android device progmatically?

后端 未结 7 1478
礼貌的吻别
礼貌的吻别 2020-12-02 18:50

I am trying to determine soft navigation bar through the android program. I didn\'t find straight way to determine. Is there anyway to find the navigation bar availability.

7条回答
  •  鱼传尺愫
    2020-12-02 19:22

    As i know you can detect it by

    boolean hasSoftKey = ViewConfiguration.get(context).hasPermanentMenuKey();
    

    But it required APIs 14+


    If above solution doesn't work for you then try below method

    public boolean isNavigationBarAvailable(){
    
            boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
            boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);
    
            return (!(hasBackKey && hasHomeKey));
        }
    

提交回复
热议问题