当我调用简单的
时,我正在使用phonegap build来编译我的android apknavigator.notification.alert(
'This is my message', // mensaje (message)
alertDismissed, // función 'callback' (alertCallback)
'Game Over', // titulo (title)
'Close' // nombre del botón (buttonName)
);
它不起作用这是我的index.html代码
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<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" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>PhoneGap</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
</script>
</body>
</html>
和我的index.js
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicity call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
app.showAlert();
console.log('Received Event: ' + id);
},
alertDismissed: function()
{
console.log('called function');
},
showAlert: function()
{
navigator.notification.alert(
'Eres el ganador!', // mensaje (message)
alertDismissed, // función 'callback' (alertCallback)
'Game Over', // titulo (title)
'Cerrar' // nombre del botón (buttonName)
);
},
};
应用程序启动并显示“设备已就绪”但警报未显示
对不起我的英文,谢谢你的帮助
答案 0 :(得分:0)
尝试在index.html的<head>
中包含所有脚本标记。我有一种感觉,设备已经没有被调用,因为它在尝试加载phonegap.js时已经“准备就绪”。