Splash Screen for android没有隐藏在PhoneGap中

时间:2014-11-04 17:22:34

标签: android cordova phonegap-plugins phonegap-build

我是移动应用程序开发和phonegap的新手。我想在我的应用程序启动时显示启动画面,并在设备准备好后隐藏它。我正在使用eclipse。

我已为Cordova安装了Splash Screen插件。我已经按照phonegap中给出的教程进行了操作。它正在显示启动屏幕,但在设备准备就绪时不会隐藏。此外,按下后退按钮后它不会退出。

下面是/res/xml/config.xml下的config.xml文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.citywide.Citizen" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="loglevel" value="DEBUG" />
<preference name="SplashScreen" value="splash" />
<preference name="SplashScreenDelay" value="5000" />
<preference name="AutoHideSplashScreen" value="false" />
<feature name="SplashScreen">
    <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<name>HelloCordova</name>
<description>
    A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
    Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
</widget>

下面是/src/package/CordovaApp.java下的CordovaApp.java:

package package.name;

import android.os.Bundle;
import org.apache.cordova.*;

public class CordovaApp extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    super.init();
    loadUrl(launchUrl);
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    super.loadUrl("file:///android_asset/www/index.html", 5000);
}
}

以下是/assets/www/index.html下的index.html文件:

<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <script type="text/javascript" src="cordova.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
//
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
    // Now safe to use device APIs
    navigator.splashscreen.hide();
    alert("here");
    }
}
</script>
    <title>Hello World</title>
</head>
<body onload="onLoad()">
    <div class="app">
        <h1>Apache Cordova</h1>
        <div id="deviceready" class="blink">
            <p class="event listening">Connecting to Device</p>
            <p class="event received">Device is Ready</p>
        </div>
    </div>
</body>

我能看到警报,但代码navigator.splashscreen.hide()没有隐藏它。

任何建议或评论都会非常感谢大家!

0 个答案:

没有答案