Results 1 to 3 of 3

Thread: Make Android back button work as default

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2014
    Posts
    13
    Answers
    2

    Default Answered: Make Android back button work as default

    Hi,
    I saw lot of posts where users ask to override the android back button, I need the opposite
    I want that, if I'm in the first/initial view, android back button work as default.
    Now, if I push the back button in the first/initial view nothing happens.

    I make the override using the back event on navigation bar:
    Code:
    onBarBack: function(bar, eOpts) {
            history.back();
            return false;
        }
    and handling the popstate:
    Code:
    window.addEventListener('popstate', function() {
        ...code here...
    }, false);
    Is there someone who can give me an hint?

  2. The hardware back button will only change the url. In the case of a single page app, it will change the hash. All your app has to do is react to the hash change and of course update the hash as the user interacts with your app.

  3. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    The hardware back button will only change the url. In the case of a single page app, it will change the hash. All your app has to do is react to the hash change and of course update the hash as the user interacts with your app.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  4. #3
    Sencha Premium Member
    Join Date
    Sep 2014
    Posts
    13
    Answers
    2

    Default

    By first thanks for the answer, the problem was related to the change of the url.
    What was wrong was in the code that I have not posted (the ...code here...), on the handler I just did pop the navigation view, so now I've added history.back() if I'm in the initial view and the app behave as I want.
    So, thank you for the hint!

Similar Threads

  1. How to make Back Button
    By cygnosis in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 2 Dec 2014, 1:12 AM
  2. How to make use of android back button??
    By mohansbala in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 5 Feb 2014, 1:44 AM
  3. Navigation back button on android htc one does not work
    By gigasweb in forum Sencha Touch 2.x: Bugs
    Replies: 1
    Last Post: 13 Jan 2014, 12:21 PM
  4. why does the back button not work on Android?
    By omarm in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 26 Apr 2012, 6:24 PM
  5. navigationbar default back button
    By nareh tank in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 16 Feb 2012, 1:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •