2

I am using Cordova 1.7 on Android, and it seems to be working (i.e: I can select an image from the gallery for example) but I can't get the back button event to fire. When pressing the back button the app automatically closes. My build target is Android 2.2.

I put this in the onReady method, exactly as the stated in the API:

document.removeEventListener("backbutton", onBackKeyDown, false);

What am I missing?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
  • try this http://stackoverflow.com/questions/10382634/how-to-prevent-android-from-closing-web-application-when-backbutton-is-pressed – sweetrenard Jun 07 '12 at 11:08

1 Answers1

3
document.addEventListener("backbutton" , onBackKeyDown, false);     

function  onBackKeyDown(){    
   // Do something here    
   alert('back button was pushed');    

}

addeventlistener, not remove event

catalin87
  • 625
  • 6
  • 19
  • Yes, sorry. this is what I did. AddEventListener... sorry I must have typed it fast without noticing. Everything used to work when I was using phonegap 1.4.1. I fear it is something to do with that. I must have missed something in the transition to cordova 1.7, although I did go over the instructions carefully. The weird thing, like I mentioned earlier, is that other Phonegap methods function as expected. Thanks for your help, Shachar – shachar albilia Jun 06 '12 at 05:10