1. #1
    Sencha User
    Join Date
    Aug 2007
    Posts
    11
    Vote Rating
    0
    rohitghatol is on a distinguished road

      0  

    Default Unanswered: Sencha Touch Routers and Android's native back button

    Unanswered: 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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    15
    Vote Rating
    0
    JimSoper is on a distinguished road

      0  

    Default Android Back Button in PhoneGap

    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
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    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 @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    When I said use navigationview.pop(), navigationview was just an example variable describing the component.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  8. #8
    Sencha User
    Join Date
    Jun 2011
    Posts
    22
    Vote Rating
    2
    bohboh is on a distinguished road

      0  

    Default


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

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    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
    Vote Rating
    2
    bohboh is on a distinguished road

      0  

    Default


    Thanks!