我使用PhoneGap Api 1.4.1,並且我嘗試使用1.5.0,PhoneGap Event volumeupbutton和volumedownbutton不起作用,它既不能在Android設備上工作,也不能在模擬器上工作。當音量按鈕向上或向下按下它必須顯示警報看到代碼:PhoneGap Event volumeupbutton和volumedownbutton不起作用
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>PhoneGap Volume Down Button Example</title>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap.js has not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("volumedownbutton", onVolumeDownKeyDown, false);
document.addEventListener("volumeupbutton", onVolumeUpKeyDown, false);
}
// Handle the volume down button
//
function onVolumeDownKeyDown() {
alert("Down");
}
function onVolumeUpKeyDown() {
alert("Up");
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
我也試過這在iphone它不工作,以及:( – AsadYarKhan 2012-03-19 13:36:38
錯誤的問題不支持在iPhone和Android:P – AsadYarKhan 2012-03-19 14:52:17
什麼是錯誤的問題?你可以自由刪除你的問題或自己回答,如果你感覺你的問題是不必要的 – 2012-03-20 11:38:04