incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugo (JIRA)" <>
Subject [jira] [Created] (CB-1205) backbutton event should not fire on 'subscribe'
Date Tue, 07 Aug 2012 05:09:02 GMT
Hugo created CB-1205:

             Summary: backbutton event should not fire on 'subscribe'
                 Key: CB-1205
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android
    Affects Versions: 2.0.0, 1.9.0, 1.8.1
            Reporter: Hugo
            Assignee: Joe Bowser

After the backbutton has been used once, it fires every time it is subscribed to. This is
a pattern that may makes sense with certain events, but it is problematic in the android world
where users will expect the backbutton to do different things depending on the context (typically,
when on the home screen the backbutton means "exit the app", and on any other screen it means
"go back to the previous screen").

For developers to be able to implement this behavior, they need to be able to subscribe and
unsubscribe the backbutton event without side-effect

The pseudo js to implement a normal android behavior is something like:
goPreviousScreen = function() {
// Do what you need to do to return to the previous screen

// When returning to the home screen, disable the cdv handler to enable the
// default behavior (exit the app & return to previous activity) 
document.removeEventListener("backbutton", goPreviousScreen, false) ;

// When leaving the home screen
document.addEventListener("backbutton", goPreviousScreen, false) ;
// >> If the user exercised the backbutton once during the session
// >> he can never navigate from the home screen to another screen
// >> without being immediatly returned to the home screen
// >> because the 'backbutton' event fires on subscription 

Note: this was tested & confirmed on 1.8.1, a cursory glance at the source for 1.9 and
2.0 strongly suggests that the problem affects these versions as well. 

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message