Need help with displaying splash screen on Android (Cordova 3.6)

I will definitely check that out. I don’t do anything special with my build hooks, in fact I don’t use them at all… The fact is that the Splashscreen plugin does need to be updated to work the same on Android as it does on iOS, but your blog post may still be very helpful until I can find the time to update the plugin. (Which might not be for a while)

Thanks

This worked for me.

  1. Add the cordova splash screen plugin using command line cordova plugin add org.apache.cordova.splashscreen

  2. Put the splash screen image in the platforms/android/res/drawable folders

  3. Put the following in the config.xml file

    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="10000" />
    
    <platform name="android">
    <splash src="platforms/android/res/drawable/screen.png" density="hdpi"/>
    

Hey your preview not showing what i entered.

1 Like

This is what works.
``

<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="10000" />
<platform name="android">
    <splash src="res/res-land-hdpi/screen.png" density="land-hdpi"/>
    <splash src="res/res-land-ldpi/screen.png" density="land-ldpi"/>
    <splash src="res/res-land-mdpi/screen.png" density="land-mdpi"/>
    <splash src="res/res-land-xhdpi/screen.png" density="land-xhdpi"/>
    <splash src="res/res-port-hdpi/screen.png" density="port-hdpi"/>
    <splash src="res/res-port-ldpi/screen.png" density="port-ldpi"/>
    <splash src="res/res-port-mdpi/screen.png" density="port-mdpi"/>
    <splash src="res/res-port-xhdpi/screen.png" density="port-xhdpi"/>
</platform>

``

So this also works with .9.png files? I had no problems with regular PNGs, but images that aren’t 9-patch run the risk of being displayed improperly (and in a very ugly way).

IMHO this is not how it was intended. Seems like you’re defining the src which is also the destination.

I currently using cordova 5 version. It works all the different versions of android devices

cordova plugin add cordova-plugin-splashscreen

<preference name="SplashScreen" value="screen" /> <preference name="SplashScreenDelay" value="10000" />

For anybody else who is banging their head against a wall, I solved this problem by downgrading cordova-plugin-splashscreen to @2.0. So run cordova plugin remove cordova-plugin-splashscreen, then cordova plugin add cordova-plugin-splashscreen@2.0. See this Stack Overflow ticket: http://stackoverflow.com/questions/35977045/ionic-splash-screen-will-not-show-in-android-on-brand-new-project/35987034?noredirect=1#comment59630856_35987034

4 Likes

Duuuuude!! THANKS. It worked like a charm

Thanks @jordancooperman. Worked for me, Thanks for sharing the downgrade workaround

In case people are struggling with this… If you are using

<preference name="orientation" value="portrait" />

in your config then you should remove “port-” and “land-” from your density attribute in your splash images:

<splash src="res/screen/android/splash-port-xhdpi_720px1280px.png" density="xhdpi"/>

After I did that it worked for me. I also have these plugin settings:

<plugin name="cordova-plugin-splashscreen" source="npm" version="3.2.1" /> <preference name="AutoHideSplashScreen" value="false" /> <preference name="FadeSplashScreen" value="true" /> <preference name="FadeSplashScreenDuration" value="500" /> <preference name="ShowSplashScreenSpinner" value="false"/> <preference name="SplashMaintainAspectRatio" value="true" /> <preference name="SplashScreen" value="screen" /> <preference name="SplashScreenDelay" value="10000" />

1 Like

this should solve it,
http://ionicframework.com/docs/cli/icon-splashscreen.html

you sir! you are awesome

I also have faced the same situation and found this setting works.

My environment is below.

  1. Cordova, IONIC in Visual Studio 2015
  2. cordova-plugin-splashscreen" version=“4.0.0” installed via Visual Studio (config.xml)

You need the followings.
1)config.xml

<plugin name="cordova-plugin-splashscreen" version="4.0.0" />
<platform name="android">
<!-- you can use any density that exists in the Android project -->
<splash src="platforms/android/res/drawable/screen.png" density="hdpi" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="10000" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashMaintainAspectRatio" value="true" />

a) The important point is that you must set the “src” as “platforms/android/res/drawable/
->I created this folder under www, so if you see the visual studio project, the directory looks like this.
->www/platforms/android/res/drawable/
(In my case if I change the folder name, splash screen does not activate)

b)file name must include the word, “screen.”
->In my case, I set the name as “screen.png
In the cordova project, file name is written as “splash-land-hdpi.png”, but this does not work.
If you look into the “SplashScreen.java (This file is in cordova-plugin-splashscreen folder)”, you can see that the program only deals with the word “screen” (not “splash”)

2)Nine-patch files
You can easily create your Nine-patch files here.
https://romannurik.github.io/AndroidAssetStudio/nine-patches.html

3)navigator.splashscreen.show() in your program
The following code is necessary in your program.

    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        navigator.splashscreen.show();
    }

hi,
my android splash screen and icon is not showing in my app. its coming default app icon. In ios its coming properly.
Please help me !

hello… I found some informative articles for displaying splash screen on Android using Cordova…

You can check this post too https://antonioleiva.com/branded-launch-screen/

Hello Sioesi, where is the place (file) to write that code? Many thank…