mirror of
https://github.com/apache/cordova-android.git
synced 2026-01-30 00:05:28 +08:00
feat: allow disabling splash screen for embedded Cordova (#1824)
This commit is contained in:
@@ -106,7 +106,9 @@ public class CordovaActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// Handle the splash screen transition.
|
||||
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
|
||||
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.
|
||||
* <p>
|
||||
* 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}
|
||||
* <p>
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user