From 8408a664e2ab22585652b7c4f2197c8050ebffe7 Mon Sep 17 00:00:00 2001
From: klirktag <[EMAIL REDACTED]>
Date: Wed, 15 Jul 2026 00:41:49 +0200
Subject: [PATCH] Android: restore the system bars when leaving fullscreen on
API 30+
My old PR #15867 switched the fullscreen path to WindowInsetsController.hide() for API 30+, because the legacy setSystemUiVisibility() flags are ignored on API 30+.
The leaving fullscreen path was left untouched: it still calls setSystemUiVisibility(SYSTEM_UI_FLAG_VISIBLE), which is equally ignored on API 30+.
As a result, once fullscreen had hidden the status/navigation bars, they never came back when returning to windowed mode.
---
.../main/java/org/libsdl/app/SDLActivity.java | 20 +++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 197edc4007cd9..ed1ffd509143a 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -1012,10 +1012,22 @@ public void handleMessage(Message msg) {
}
SDLActivity.mFullscreenModeActive = true;
} else {
- int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
- window.getDecorView().setSystemUiVisibility(flags);
- window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
- window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
+ // The legacy setSystemUiVisibility() flags are ignored on
+ // API 30+, so the bars hidden by the modern enter path above
+ // would never come back. Restore them via WindowInsetsController.
+ final WindowInsetsController controller = window.getInsetsController();
+ if (controller != null) {
+ controller.setSystemBarsBehavior(
+ WindowInsetsController.BEHAVIOR_DEFAULT);
+ controller.show(WindowInsets.Type.systemBars());
+ }
+ } else {
+ int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_VISIBLE;
+ window.getDecorView().setSystemUiVisibility(flags);
+ window.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+ window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
SDLActivity.mFullscreenModeActive = false;
}
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {