我正在使用 ember 为 android 开发 phonegap 1.9.0 应用程序,并且我试图在应用程序加载后隐藏我的启动屏幕,而不是等待指定的超时。
我的启动画面显示,但我无法成功调用
navigator.splashscreen.hide()
包含此行会导致错误:
Error: SyntaxError: Unexpected token ' at file:///android_asset/src/cordova-1.9.0.js:1012
我尝试再次下载 cordova-1.9.0.js 并使用 2.0.0 版本,但遇到了同样的问题。
这是我的 html/js。
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" title="master" type="text/css" href="css/master.css" />
<title>Cordova Device Ready Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"> </script>
<script type="text/javascript" charset="utf-8" src="jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="ember-0.9.8.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to make calls Cordova methods
function onDeviceReady() {
// Now safe to use the Cordova API
console.log("device ready...")
navigator.splashscreen.hide()
}
</script>
</head>
<body onload="onLoad()">
<div id="content"></div>
</body>
</html>
和活动代码...
public class myApp extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/src/index.html", 5000);
}
}