Is there a way? For Android 4 upwards (= Android without navigation by gestures)?
The question was about the navigation bar.
![]()
Hi
Some information
I’ve already been down the Google road. I couldn’t get anything to work. I didn’t bother to try the solutions for higher Android versions since I need one for Android 4 and upwards. Does nobody have working Processing code?
Thanks, that was very helpful. Your test app has no navigation bar but mine has. It turns out I must have fullScreen() in the settings() function, if there is a settings() function, and I can not even have an if condition around it, like:
if (TARGET_ANDROID)
{
fullScreen();
}
One problem remains: When calling up the keyboard, the navbar comes back but won’t disappear after the keyboard has been closed.
You might have to call hideSystemUI()
Have a look at the code near the end of this thread
Bugs observed since adding fullScreen():
-
On my Android 9 SamsungS8+ phone, fullScreen() makes the navigation buttons disappear but not the bar behind them. The bar is always displayed and obscures a part of my app.
-
On my Android 6 Huawei M10 8.0 tablet, fullScreen() makes the navigation buttons/bar disappear but only until the soft keyboard is displayed. Then they come back and stay for good, even after the keyboard is closed. Additionaly, every 1-2 minute, I see a flicker on the screen. I recorded that with a camera to discover more and it turns out that for a fraction of a second, the screen content of my app is shifted down by ~1cm?!
-
On my OS Galaxy Tab 10 with Lineage OS 17 (= Android 10), fullScreen() has no issues.
So unfortunately, this is not a workable solution. I use Processing 3 and Android mode 4.1.1 but I tried Processing 4.3 and the latest Android mode, too, without a better result.
You might have to call hideSystemUI()
My installation does not seem to know the constants (only tried this with Processing 3). I defined them myself but it seems hideSystemUI() never gets called after closing the keyboard with the back button.
import android.view.View;
final int SYSTEM_UI_FLAG_IMMERSIVE = 2048 ;
final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 256;
final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512 ;
final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024 ;
final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2;
final int SYSTEM_UI_FLAG_FULLSCREEN = 4;
// for Android, comment out under Java
public void
onWindowFocusChanged(boolean hasFocus)
{
this.getActivity().onWindowFocusChanged(hasFocus);
if (hasFocus)
hideSystemUI();
}
private void
hideSystemUI()
{
// Enables regular immersive mode. For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE. Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
View decorView = getActivity().getWindow().getDecorView();
decorView.setSystemUiVisibility
(
SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the content doesn't resize when the system bars hide and show.
| SYSTEM_UI_FLAG_LAYOUT_STABLE
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
| SYSTEM_UI_FLAG_HIDE_NAVIGATION
| SYSTEM_UI_FLAG_FULLSCREEN
);
println("called");
}
I had forgotten about this, but that code is old … deprecated a few years back … this link explains …
This code seems to work …
import android.view.*;
import android.os.Build;
void settings() {
fullScreen() ;
}
void setup() {
}
void draw() {
}
void mousePressed() {
openKeyboard() ;
}
public void
onWindowFocusChanged(boolean hasFocus)
{
getActivity().onWindowFocusChanged(hasFocus);
if (hasFocus)
hideSystemUI();
}
private void
hideSystemUI()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { //api 30 & higher
final WindowInsetsController controller = getWindow().getInsetsController();
if (controller != null)
controller.hide(WindowInsets.Type.statusBars());
} else {
//use old method ?
//View decorView = getWindow().getDecorView();
//decorView.setSystemUiVisibility(
// View.SYSTEM_UI_FLAG_IMMERSIVE
// // Set the content to appear under the system bars so that the
// // content doesn't resize when the system bars hide and show.
// | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// // Hide the nav bar and status bar
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_FULLSCREEN);
}
}
depreceated
Just depreceated or not working anymore? I was looking for a solution for Android 4 and upwards and I’m using an older processing (3.4 from 2018) and an older Android mode (4.1.l) from that time.
-
I have SDK for API Level 28 (Android 9.0). I think the SDK was installed via Android Studio (I don’t remember how I installed it and why exactly API level 28). Is that why I don’t have View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION etc.? Does Google remove depreceated symbols? Compile error: “The primitive type int of View does not have a field SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION”
-
Why does it appear as if onWindowFocusChanged() is never called?
public void
onWindowFocusChanged(boolean hasFocus)
{
getActivity().onWindowFocusChanged(hasFocus);
println("called");
}
I never see “called” in the console. If I use surfaceWindowFocusChanged() instead of onWindowFocusChanged(), I get calls but not in the context of showing/hiding the keyboard, only upon start and upon exit.
I don’t know the answers … I just post code that I have been able to use, although this is using the processing library in Android Studio. When I try with Processing I get the same as you. I suspect that Processing’s Android Mode isn’t using some recent updates & requirements related to this. Perhaps raise a GitHub issue asking for fixes to this? I will play a bit more and post if I find anything.
Hello shedMusic.
Many thanks for your suggestion. On my redmi 13 the code works fine!!!
Mauro
That’s great to hear … ![]()
