I want to know if a device has a soft navigation bar. I use the following code for this purpose:
val hasNavBar = resources.getIdentifier("config_showNavigationBar", "bool", "android")
if(hasNavBar > 0 && resources.getBoolean(hasNavBar)){
val resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
if (resourceId > 0) {
ApiHelper.navHeight = resources.getDimensionPixelSize(resourceId)
}
}
But on some devices that have no soft navigation bar, resources.getDimensionPixelSize(resourceId)
gives some height and hasNavBar
is true.
The device with this problem is a Redmi Note 4 Pro. I don't know if other devices have the same problem.