【发布时间】:2014-11-27 16:31:28
【问题描述】:
我创建了一个新的 Cordova 4.0 项目,添加了 android 平台并添加了所有核心插件,以下是我的 index.html 文件。
<!DOCTYPE html> <html> <head>
<title>Notification Example</title>
<script type="text/javascript" charset="utf-8" src="/cordova.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() {
alert("ready");
}
// Show a custom alert
//
function showAlert() {
navigator.notification.alert(
'You are the winner!', // message
'Game Over', // title
'Done' // buttonName
);
}
// Beep three times
//
function playBeep() {
navigator.notification.beep(3);
}
// Vibrate for 2 seconds
//
function vibrate() {
navigator.vibrate(2000);
}
</script> </head> <body>
<p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
<p><a href="#" onclick="playBeep(); return false;">Play Beep</a></p>
<p><a href="#" onclick="vibrate(); return false;">Vibrate</a></p> </body> </html>
但我永远无法看到设备准备好发射。关于 abive sn-p 有什么问题的任何想法?
【问题讨论】:
-
将
src="/cordova.js"更改为src="cordova.js"。希望它有效! -
我删除了所有添加的插件,删除了 android platform ,将其添加回来,然后又添加了所有插件。听起来不太好,但它现在正在工作。我将尝试使用新的 Cordova 项目再次重现它。截至目前,振动和哔哔声正在工作。设备就绪上的就绪消息仍未显示,并且 showAlert 功能仍然无法正常工作。我不确定为什么 device ready 不会触发。