PhoneGap构建Android不显示Splashscreen

时间:2017-08-22 17:47:22

标签: android cordova phonegap-build splash-screen phonegap

以下是我的config.xml中与启动屏幕相关的代码:

variables = locals()
for i in range(1,4):
    variables["df{0}".format(i)] = df.loc[(df['index']>=i)&(df['index']<=i+2),]

在iOS上,启动画面显示完美但在Android上根本没有显示任何内容。有没有人对如何修复此错误有任何建议?我已经尝试添加cordova s​​plashscreen插件,但这似乎使Android应用程序崩溃。我错过了另一段重要的代码吗?

1 个答案:

答案 0 :(得分:0)

我为你创建了一个样本,我检查了设备并且出现了闪屏。

添加插件

  

科尔多瓦-插件-溅射屏幕

的index.html

<!DOCTYPE html>
<html>
  <head>
    <title>Splashscreen Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" src="js/PushNotification.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    //
    function onDeviceReady() {
        navigator.splashscreen.show();
    }

    </script>
  </head>
  <body>
    <h1>Example</h1>
  </body>
</html>

config.xml中

    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <platform name="android">            
            <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png" />
            <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png" />
            <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png" />
            <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
            <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
            <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        </platform>
<plugin name="cordova-plugin-splashscreen" spec="~3.2.1" />

我创建了一个名为“resources”的文件夹并添加了启动画面图像并在config.xml文件中给出了它的路径。

它正在发挥作用。