I am trying to check the visibility of the navigation bar. On the Samsung Galaxy S8 I can toggle the navigation bar visibility.
I have tried a lot of different ways to check the visibility, but none of them work on the Galaxy S8.
Some examples: (They will always return the same value, no matter it is shown or hidden)
ViewConfiguration.get(getBaseContext()).hasPermanentMenuKey()
always returns false
KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK)
always returns false
KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME)
always returns true
Even by figuring out the navigation bar height (How do I get the height and width of the Android Navigation Bar programmatically?), it will not work.
Maybe this will be useful for someone. The user can hide the navigation bar, so the best way to detect visibility is to subscribe to this event. It works.