Enables developers to show/hide the application's splash screen.
<pluginname="SplashScreen"value="org.apache.cordova.SplashScreen"/>
Add an entry under the Plugins dictionary -with the key "SplashScreen"and value "CDVSplashScreen".
New projects should already have this key.
Copy your splash screen image into the res/drawable directories of your Android project. The sizes of each image should be:
It is highly recommended that you use a 9-patch image for your splash screen.
In the onCreate method of the class that extends DroidGap add the following two lines:
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",10000);
The first line 'super.setIntegerProperty' sets the image to be displayed as the splashscreen. If you have named your image anything other than splash.png you will have to modify this line. The second line is the normal 'super.loadUrl' line but it has a second parameter which is the timeout value for the splash screen. In this example the splash screen will display for 10 seconds. If you want to dismiss the splash screen once you get the "deviceready" event you should call the navigator.splashscreen.hide() method.
Copy your splash screen images into the Resources/splash directory of your iOS project. Only add the images for the devices you want to support (iPad screen size or iPhone screen size). The sizes of each image should be:
Displays the splash screen.
navigator.splashscreen.show();
navigator.splashscreen.show() displays the applications splash screen.
navigator.splashscreen.show();
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<scripttype="text/javascript"charset="utf-8"src="cordova-2.2.0.js"></script>
<scripttype="text/javascript"charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady,false);
// Cordova is ready
//
function onDeviceReady(){
navigator.splashscreen.show();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
Dismiss the splash screen.
navigator.splashscreen.hide();
navigator.splashscreen.hide() dismisses the applications splash screen.
navigator.splashscreen.hide();
<!DOCTYPE html>
<html>
<head>
<title>Splashscreen Example</title>
<scripttype="text/javascript"charset="utf-8"src="cordova-2.2.0.js"></script>
<scripttype="text/javascript"charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady,false);
// Cordova is ready
//
function onDeviceReady(){
navigator.splashscreen.hide();
}
</script>
</head>
<body>
<h1>Example</h1>
</body>
</html>
In your Cordova.plist, you need to modify the value for "AutoHideSplashScreen” to false
Then, if you want to delay hiding the splash screen for 2 seconds, you can do this in your deviceready event handler:
setTimeout(function(){
navigator.splashscreen.hide();
},2000);