From c2cf589d84de260a200e4f22939e234d8d1ba42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Wed, 16 Jul 2025 14:34:03 +0900 Subject: [PATCH] feat: allow disabling splash screen for embedded Cordova (#1824) --- .../org/apache/cordova/CordovaActivity.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 50d6b323..f0ae6e1c 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -106,7 +106,9 @@ public class CordovaActivity extends AppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { // Handle the splash screen transition. - splashScreen = SplashScreen.installSplashScreen(this); + if (showInitialSplashScreen()) { + splashScreen = SplashScreen.installSplashScreen(this); + } // need to activate preferences before super.onCreate to avoid "requestFeature() must be called before adding content" exception loadConfig(); @@ -157,7 +159,9 @@ public class CordovaActivity extends AppCompatActivity { cordovaInterface.onCordovaInit(appView.getPluginManager()); // Setup the splash screen based on preference settings - cordovaInterface.pluginManager.postMessage("setupSplashScreen", splashScreen); + if (showInitialSplashScreen()) { + cordovaInterface.pluginManager.postMessage("setupSplashScreen", splashScreen); + } // Wire the hardware volume controls to control media if desired. String volumePref = preferences.getString("DefaultVolumeStream", ""); @@ -537,4 +541,20 @@ public class CordovaActivity extends AppCompatActivity { } } + + /** + * Indicates whether to show the splash screen while the WebView is initially loading. + *

+ * This method is available for native apps that embed a Cordova WebView. + * Native apps most likely already have their own splash screen setup. + * This option is not configurable for Cordova CLI–created apps. + * + * @return {@code true} + *

+ * To disable the initial splash screen, override this method and return {@code false} + * in your activity that extends {@link CordovaActivity}. + */ + protected boolean showInitialSplashScreen() { + return true; + } }