Update SDLActivity.java

Enabled immersive mode on Android devices during onCreate in the lifecycle.
This commit is contained in:
Patrick Babb
2025-05-04 23:53:45 -05:00
committed by GitHub
parent e6a99ca9ac
commit ccd421598e
@@ -1115,24 +1115,49 @@ public class SDLActivity extends Activity implements OnKeyListener {
} }
// Setup // Setup
@Override private void enterImmersiveMode() {
protected void onCreate(Bundle savedInstanceState) { final View decorView = getWindow().getDecorView();
//Log.d(TAG, "onCreate()"); decorView.setSystemUiVisibility(
super.onCreate(savedInstanceState); View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
enterImmersiveMode();
}
}
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll()
.build(); @Override
StrictMode.setThreadPolicy(policy); protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main); super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// So we can call stuff from static callbacks StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
mSingleton = this; StrictMode.setThreadPolicy(policy);
mContext = this.getApplicationContext();
RES_FILENAME = getResourceName(); setContentView(R.layout.main);
StorageOptions.determineStorageOptions(mContext);
checkStorageLocationPreference(); // Enable immersive mode
prepareOptionMenu(null); enterImmersiveMode();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
// So we can call stuff from static callbacks
mSingleton = this;
mContext = this.getApplicationContext();
RES_FILENAME = getResourceName();
StorageOptions.determineStorageOptions(mContext);
checkStorageLocationPreference();
prepareOptionMenu(null);
}
public void forceResDownload(final File oldRes) { public void forceResDownload(final File oldRes) {
AlertDialog.Builder resChooser = new AlertDialog.Builder(this); AlertDialog.Builder resChooser = new AlertDialog.Builder(this);