Cordova 3.4 Splashscreen not working

我是研究僧i 提交于 2019-12-12 09:44:22

问题


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.


回答1:


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.

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.

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

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




回答2:


I was having the same issue after the 2.5.1 CLI update. If i run the same project in the VisualStudio ionic simulator all works fine. It also works fine when I run the app in the 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



来源:https://stackoverflow.com/questions/25513126/cordova-3-4-splashscreen-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!