Cordova 3.4 Splashscreen does not work

I have an Android Phonegap proyect and I am trying to use the Splashscreen plugin that Cordova provides. I think I have everything set up correctly ... Here are the code snippets that 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 installed the plugin correctly from the CLI and the splash itself is in the res / drawable * folders in the android project as I think it should be, but no matter what I try, the splash is not showing. Not even the default. Even if I disable the navigator.splashscreen.hide () function (in case it was too fast).

Now I'm completely lost, trying to work for weeks on end, but I just can't see it.

+3


source to share


2 answers


I am using cordova v3.6.3 in my android project.

I read the API and plugins documentation, but I confused some of the options in config. but i found the perfect solution.

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

2.refer to my directory structure for understanding.

enter image description here

3. Add the following codes to your config.xml file.    ※ Do not change value = "screen". you just change the src and delay value for your snapshot 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. Remove the "screen.png" file from the drawing directory for understanding.

enter image description here

5. Build your project on the command line (corova build android) and browse the directory again.

I promise you will succeed. :-)

+8


source


I had the same problem after updating 2.5.1 CLI. If I run the same project in the VisualStudio ionic simulator everything works fine. It also works great when I run my app in bowser with Telerik platform. I just need to comment out navigator.splashscreen.hide (); in my project for the latest CLI simulator, or I just get a plain white screen. James



0


source







All Articles