启动应用程序时不显示启动画面。 PhoneGap / Cordova

时间:2019-04-03 18:17:42

标签: cordova cordova-plugins phonegap-plugins phonegap

我正在使用PhoneGap桌面应用程序和PhoneGap Build来制作和编译Android应用程序。 我想在应用程序的开头显示启动屏幕,因为我要在后台执行一些加载工作,一旦加载完成,我就会隐藏启动屏幕并显示内容。

我使用的是“ cordova-plugin-splashscreen v5.0.2”,我使用此代码来显示和隐藏初始屏幕:

//Show Splash Screen
navigator.splashscreen.show();

//Hide splash Screen after loading has finished
navigator.splashscreen.hide();

这是我的config.xml文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>NexusPhoneGap</name>
    <description>
        A blank PhoneGap app.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <content src="index.html" />
    <access origin="*" />

    <plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />

    <platform name="android">
        <splash src="splashScreens/screen-hdpi-portrait.png" density="port-hdpi"/>
        <splash src="splashScreens/screen-ldpi-portrait.png" density="port-ldpi"/>
        <splash src="splashScreens/screen-mdpi-portrait.png" density="port-mdpi"/>
        <splash src="splashScreens/screen-xhdpi-portrait.png" density="port-xhdpi"/>
    </platform>

</widget>

如您在config.xml中看到的,我将初始屏幕放在名为“ splashScreens”的文件夹中。 问题是没有出现启动画面。我看到的是空白屏幕,而不是启动屏幕。知道如何显示启动画面吗?

1 个答案:

答案 0 :(得分:0)

我为此苦了很长时间。我也有一个旧的非标准项目配置和路径。将“密度”更改为“限定词”是可行的。 所以改变

a < b

public static int GetSum(int a, int b) {
    if (a < b) {
        return (b*(b+1) - (a-1)*a) / 2;
    } else if (a == b) {
        return a;
    } else {
        throw new ArgumentException($"{nameof(a)} must be less than or equal to {nameof(b)}.").
    }
}