Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Sencha Touch Routers and Android's native back button

  1. #1

    Default Sencha Touch Routers and Android's native back button

    Hi All,
    I have been working with Sencha Touch SDK and Tools (2.0.1 rc) hoping to see few improvements on native packaging.

    Question I have is

    Given I have an Sencha Touch 2 Application which uses routers and on navigation from one view to another view (the url changes from http://xyz.com/#home to http://xyz.com/#places ). Now if I package this application as android native application and launch it on Android Phone. And now If I navigate from say home view to places views and I hit native back button on android, What would happen today

    1. Would my application stay there and I can see a navigation say back to home view?
    2. Would my application close and I see the previous application/home screen of android?

    I am trying this out, my conclusion is coming to the 2nd part, which I am pretty disappointed with. In case point 2 is how things work, then I will back to use PhoneGap underneath my Sencha Touch App.

    Any answers or hints are welcome.

    For people who will ask for a sample app, I am attaching Source-Code.zip (I removed resources and sdk folder) for you to try out. Let me know what am I doing wrong here. I am using ICS phone (Samsung Nexus S).

    I am not able to get the back button in android working for android native apps, despite using routes

    Cheers,
    Rohit
    Attached Files Attached Files

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

    Default

    Native apps and their behavior aren't really taken into account a web site may be running within it. You would have to override the back button to accomplish what you want.
    Mitchell Simoens @LikelyMitch

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

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

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    15

    Default Android Back Button in PhoneGap

    To listen for and intercept Android hardware back button presses, it looks like you will
    need to use PhoneGap. Look at
    http://docs.phonegap.com/en/1.0.0/ph...tml#backbutton

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97

    Default

    I have the back button successfully overridden, any one have an example of manually firing a navigation view's back button?

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

    Default

    Quote Originally Posted by bwags View Post
    I have the back button successfully overridden, any one have an example of manually firing a navigation view's back button?
    Code:
    navigationview.pop();
    Mitchell Simoens @LikelyMitch

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

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

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97

    Default

    I kept getting errors for missing methods when I tried that. Finally settled on Ext.Viewport.getActiveItem().pop();

    Which always called pop on my viewport anyway. Anything wrong with doing it that way?

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

    Default

    When I said use navigationview.pop(), navigationview was just an example variable describing the component.
    Mitchell Simoens @LikelyMitch

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

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

  8. #8
    Sencha User
    Join Date
    Jun 2011
    Posts
    22

    Default

    Can you post example code of you how overrode the back button?

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    97

    Default

    Quote Originally Posted by bohboh View Post
    Can you post example code of you how overrode the back button?
    In launch:

    Code:
            document.addEventListener("backbutton", this.backKeyDown, false);
    In a function just beneath launch:

    Code:
        
    backKeyDown : function() {        // Ext.Viewport.getActiveItem().pop() return the class it popped, if undefined quit app.
            if (Ext.Viewport.getActiveItem().pop == undefined || Ext.Viewport.getActiveItem().pop() == undefined) {
                navigator.app.exitApp();
            }
        }
    Note...Cordova/PhoneGap makes that possible.

  10. #10
    Sencha User
    Join Date
    Jun 2011
    Posts
    22

    Default

    Thanks!

Page 1 of 2 12 LastLast

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
  •