Back button event on Cordova 1.5 - not triggering

2,668 views
Skip to first unread message

Robert Kern

unread,
Mar 6, 2012, 8:56:26 PM3/6/12
to phon...@googlegroups.com
I have just updated to Cordova 1.5 and have found that the "backbutton" event no longer seems to get fired.

I can see this log message in LogCat (when debugging the app from Eclipse):

DroidGap(2354): WARNING: Back Button Default Behaviour will be overridden.  The backbutton event will be fired!

This indicates to me that the backbutton even has been registered properly.  The code i use to register the handler is:

document.addEventListener('backbutton', onBackKeyDown, true);

function onBackKeyDown(e) {
    console.log('back button pressed');
}

But the console message is never displayed.

I recall that there have been problems with the backbutton even in some previous versions of PhoneGap and wondered if this was something other people are experiencing, and if the PhoneGap/Cordova team are aware of it.

Thanks,

Robert

dhavaln

unread,
Mar 12, 2012, 3:04:07 AM3/12/12
to phon...@googlegroups.com

Bryce Curtis

unread,
Mar 13, 2012, 5:14:39 PM3/13/12
to phon...@googlegroups.com
Cordova is being re-initialized on every new page load, which will cause several problems - including the one you are experiencing.  I have a fix if you want to try it out...

In cordova-1.5.0.js, change

    channel.onNativeReady.subscribe(_self.boot);

to

    channel.onNativeReady.subscribeOnce(_self.boot);

If that solves the problem, then I will push the fix.

Thanks,
Bryce

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com

Robert Kern

unread,
Mar 18, 2012, 10:46:07 PM3/18/12
to phon...@googlegroups.com
Hi Bryce,

Yes that change does seem to fix the back button issue.


Thanks!

Robert

Balakumar

unread,
Mar 28, 2012, 6:19:57 PM3/28/12
to phon...@googlegroups.com
    Thanks Robert !


    Adding the below code to my cordova-1.5.0.js helped  me to fix the ajax issue.


    channel.onNativeReady.subscribe(_self.boot); 

    to 

    channel.onNativeReady.subscribeOnce(_self.boot); 





Brian Knorr

unread,
Apr 4, 2012, 6:50:42 PM4/4/12
to phon...@googlegroups.com
This doesn't work for me at all.  Now the backbutton event never fires.

Roberto Martino

unread,
Apr 8, 2012, 12:43:22 PM4/8/12
to phon...@googlegroups.com
try to move the registration of the "backbutton" event inside the funcion called by the "deviceready" event
Reply all
Reply to author
Forward
0 new messages