i have a problem with some Events in PhoneGap. When i try to register an event-listener to the pause and backbutton event for an phonegap-app (build on PhoneGap-Build) the events aren't recognized.
My code looks like the following:
function onBackKeyDown() {
console.log("Back");
}
function onMenuKeyDown() {
console.log("Menu");
}
function pause() {
console.log("Menu");
}
function ready(){
console.log("ready");
document.addEventListener("pause", pause, false);
document.addEventListener("backbutton", onBackKeyDown, false);
document.addEventListener("menubutton", onMenuKeyDown, false);
}
document.addEventListener("deviceready", ready, false);
If i run this app on a HTC Wildfire i can see in the logs, that the function ready is reached (the output is done). But if i hit the Back or search button or exit the app, then no other function is called.
Can anyone help me with this?
Thanks!
The rest of my code looks like the following (I just wrote a small example to be sure that there are no errors in my code...)
main.js:
function onBackKeyDown() {
console.log("Back");
alert("Back");
}
function onMenuKeyDown() {
console.log("Menu");
alert("Menu");
}
function onMenuSearch() {
console.log("onMenuSearch");
alert("onMenuSearch");
}
function pause() {
console.log("Menu");
alert("Pause");
}
function onResume(){
console.log("Resume");
alert("Resume");
}
function ready(){
alert("Ready");
console.log("ready");
document.addEventListener("pause", pause, false);
document.addEventListener("backbutton", onBackKeyDown, false);
document.addEventListener("menubutton", onMenuKeyDown, false);
document.addEventListener("searchbutton", onMenuSearch, false);
document.addEventListener("resume", onResume,false);
}
document.addEventListener("deviceready", ready, false);
index.html
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
</head>
<body>
<!-- Add your site or application content here -->
<p>Hello world! This is HTML5 Boilerplate.</p>
<script src="js/main.js"></script>
</body>
</html>
As I already said, I am using PhonegapBuild to build the application over several platforms, therfore i do not have the cordova script integrated in my application.
Thanks...