简体   繁体   English

Cordova 3.4 Splashscreen无法正常工作

[英]Cordova 3.4 Splashscreen not working

I have an Android Phonegap proyect and I'm trying to use the Splashscreen plugin Cordova provides. 我有一个Android Phonegap proyect,我正在尝试使用Cordova提供的Splashscreen插件。 I think I have everything correctly set... Here are the pieces of code I think are relevant. 我想我已经正确设置了所有内容......以下是我认为相关的代码片段。

Config.xml config.xml中

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

Index.html 的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. 我已经使用CLI正确安装了插件,并且启动本身位于Android项目中的res / drawable *文件夹中,我认为应该如此,但无论我尝试做什么,启动都没有显示。 Not even a default one. 甚至不是默认的。 Not even if I disable the navigator.splashscreen.hide() function (in case it was too fast). 即使我禁用navigator.splashscreen.hide()函数(如果它太快)也没有。

I'm absolutely lost now, have been trying tweaks for a week but I just can't see it. 我现在绝对迷路了,已经尝试了一周的调整,但我只是看不到它。

I'm using cordova v3.6.3 in my android project. 我在我的android项目中使用cordova v3.6.3。

I read a API & Plugin Documentations but, I confused the some options in config. 我读了API和插件文档但是,我混淆了配置中的一些选项。 but, I found a perfect solution. 但是,我找到了一个完美的解决方案

1. above all, you don't need to use "navigator.splashscreen.hide()" or ".show()" in Android project. 1.首先,你不需要在Android项目中使用“navigator.splashscreen.hide()”或“.show()”。

2. refer my directory structure for understanding clearly. 2.参考我的目录结构以便清楚地理解。

在此输入图像描述

3. Add following codes into your config.xml file. 3.将以下代码添加到config.xml文件中。 ※ Do not change the value="screen". ※请勿更改value =“screen”。 you just change the src and delay value for your splashscreen image. 您只需更改启动画面图像的src和延迟值即可。

[Config.xml] [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. 4.从drawable目录中删除“screen.png”文件以便清楚地理解。

在此输入图像描述

5. build your project on your command line (cordova build android) and, look again drawable directory. 5.在你的命令行上构建你的项目(cordova build android),然后再看一下drawable目录。

I'll promise, you'll success. 我保证,你会成功的。 :-) :-)

I was having the same issue after the 2.5.1 CLI update. 在2.5.1 CLI更新后,我遇到了同样的问题。 If i run the same project in the VisualStudio ionic simulator all works fine. 如果我在VisualStudio离子模拟器中运行相同的项目一切正常。 It also works fine when I run the app in the bowser with Telerik Platform. 当我使用Telerik平台在bowser中运行应用程序时,它也可以正常工作。 I just need to comment out navigator.splashscreen.hide(); 我只需要注释掉navigator.splashscreen.hide(); in my project for the latest CLI simulator or I just get a plain white screen. 在我的最新CLI模拟器的项目中,或者我只是得到一个纯白色的屏幕。 James 詹姆士

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM