On some devices such as Samsung S8, navigation bar can be hide or show, that's a question in some condition. Samsung S8's navigation bar can be hide or show by click left bottom button
I didn't find straight way to determine even if in the Android sources code.
And I google some issues, such as A good solution to check for navigation bar , but it doesn't help.
Any help is very appreciated.
It's a nice mixture of Android 9 Pie and Android 10 gestures. Go through the steps below to make changes. Step 1: Open the Settings app on your Samsung device. Step 2: Navigate to the Display > Navigation Bar > Full screen gestures > More options > Swipe from bottom.
Using the Show and hide button at the left side of the navigation bar, you can set the navigation bar to be hidden or pinned on the screen when you use apps or features. The navigation bar is pinned by default.
Go to Settings > Display > Navigation Bar. Tap the toggle beside Show and hide button to switch it to the on position. If you don't see this option, check for any available software updates. The update might not be out all carrier-specific Galaxy S8 phones yet.
First, credit the original author: https://www.jianshu.com/p/ddfbabd614b6
For the Samsung phones (i.e, S8, S9, etc) you can detect if the navigation bar is showing via listening to a Samsung event.
private static final String SAMSUNG_NAVIGATION_EVENT = "navigationbar_hide_bar_enabled";
Then just listen to this event, and do your thing:
private void checkNavigationBar() {
if (isSamsungVersionNougat()) { // check if Samsung phones
// detect navigation bar
try {
// there are navigation bar
if (Settings.Global.getInt(activity.getContentResolver(), SAMSUNG_NAVIGATION_EVENT) == 0) {
// Your code
// example: galleryViewModel.navigationBarHeight.set(getNavigationBarHeight());
} else { // there are no navigation bar
// Your code
// example: galleryViewModel.navigationBarHeight.set(0);
}
} catch (Exception ignored) {
}
barHideEnableObserver = new BarHideEnableObserver(new Handler());
activity.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(SAMSUNG_NAVIGATION_EVENT),
true, barHideEnableObserver);
} else {
galleryViewModel.navigationBarHeight.set(getNavigationBarHeight());
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With