Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova 3.4 Splashscreen not working

I have an Android Phonegap proyect and I'm trying to use the Splashscreen plugin Cordova provides. I think I have everything correctly set... Here are the pieces of code I think are relevant.

Config.xml

<widget ...>
    ...
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="15000" />
    <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
</widget>

Index.html

<script type="text/javascript" charset="utf-8">
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    function onDeviceReady() {
        navigator.splashscreen.hide()
    }
</script>

I have correctly installed with the CLI the plugin and the splash itself is in the res/drawable* folders in the Android project as I think it should be, but regardless of what I try to do, the splash is not showing. Not even a default one. Not even if I disable the navigator.splashscreen.hide() function (in case it was too fast).

I'm absolutely lost now, have been trying tweaks for a week but I just can't see it.

like image 840
Murray Avatar asked Feb 13 '23 04:02

Murray


1 Answers

I'm using cordova v3.6.3 in my android project.

I read a API & Plugin Documentations but, I confused the some options in config. but, I found a perfect solution.

1. above all, you don't need to use "navigator.splashscreen.hide()" or ".show()" in Android project.

2. refer my directory structure for understanding clearly.

enter image description here

3. Add following codes into your config.xml file. ※ Do not change the value="screen". you just change the src and delay value for your splashscreen image.

[Config.xml]

<platform name="android">
    <splash src="www/res/screen/android/screen-default.png" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="4000" />

4. delete a "screen.png" file from drawable directory for understanding clearly.

enter image description here

5. build your project on your command line (cordova build android) and, look again drawable directory.

I'll promise, you'll success. :-)

like image 70
Smith Lee Avatar answered Feb 15 '23 11:02

Smith Lee