To have a splash screen in the Android PhoneGap application, you need to put your splash.png file in res/drawable-ldpi , res/drawable-mdpi , res/drawable-hdpi , res/drawable-xhdpi . If these catalogs are low, medium, high and extra large dots per inch. You will need to resize splash.png (the file name is important here) for each directory, or Android will expand it for you.
The dimensions of each image should be:
- xlarge (xhdpi): at least 960 x 720
- large (hdpi): at least 640 x 480
- medium (mdpi): at least 470 x 320
- small (ldpi): at least 426 x 320
Then, in your main Java class that extends DroidGap, you need to add one line and change another. First add:
super.setIntegerProperty("splashscreen", R.drawable.splash);
this line should be displayed under super.onCreate , but before super.loadUrl . You will then need to change your loadUrl method to pause for 5 seconds before loading the main page. It will look like this:
super.loadUrl("file:///android_asset/www/index.html", 5000);
That should do it for you.
I recently made some updates on how SplashScreen works on PhoneGap Android. The main application now loads while the splash screen is displayed. This is a big improvement over the previous screen blocking gap. Learn more about the changes to my blog .
Simon MacDonald Nov 16 '11 at 18:57 2011-11-16 18:57
source share