@SimpleFunction(description = "Hides or shows the status bar (true to hide, false to show).")
public void HideStatusBar(final boolean hide) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Activity activity = form.getActiveForm();
if (activity == null) {
android.util.Log.e("BarMode", "Activity is null");
return;
}
Window window = activity.getWindow();
if (hide) {
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
android.util.Log.d("BarMode", "StatusBar hidden");
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
android.util.Log.d("BarMode", "StatusBar shown");
}
}
});
}
@SimpleFunction(description = "Hides or shows the navigation bar (true to hide, false to show).")
public void HideNavigationBar(final boolean hide) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Activity activity = form.getActiveForm();
if (activity == null) {
android.util.Log.e("BarMode", "Activity is null");
return;
}
Window window = activity.getWindow();
View decorView = window.getDecorView();
if (hide) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
android.util.Log.d("BarMode", "NavigationBar hidden");
} else {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
android.util.Log.d("BarMode", "NavigationBar shown");
}
}
});
}
The second method does not work on Android 15+ if the Navbar has already been colored.
(My approach prevents the Navbar from being colored on Android 15+, so this HideNavbar method also works on Android 15+.)







