android back button

Thread is closed for posting
3 posts, 0 answers
  1. Michael
    Michael avatar
    151 posts
    Member since:
    Jan 2012

    Posted 28 Jul 2014 Link to this post

    Is there any way to control what the device back button does on an app?

    We have a lot of modals and dynamic DOM manipulations that really alter the intuitive flow of the navigation. Is it possible to define where "back" goes? Or better yet, to have it trigger some JavaScript behavior within the app?
  2. Martin Yankov
    Martin Yankov avatar
    177 posts

    Posted 31 Jul 2014 Link to this post

    Hello Michael,

    You can use the Cordova backbutton event by adding an event listener to it. This event is fired when the hardware back button is tapped. You can find more information regarding the event and sample code here.

    The code for navigation inside the backbutton event handler depends largely on the js framework you are using. If you are using Kendo Mobile, you can use the navigate() function. It provides functionality to navigate to remote and local views and to navigate back to the previous view. You can view and try out code samples of the navigate() function here.

    Depending on your scenario, you can also use the replace() method. It navigates to a chosen remote or local view, but also removes the current view from the navigation history. This means that the back button will skip the replaced view. You can see a code sample of the replace() function here.

    Let me know if these work for you. If you are having trouble with achieving your goal, please open a support ticket and provide us your project and clear instructions regarding what you want to achieve. We can review it and provide a more concrete solution.

    I am looking forward to your reply.

    Martin Yankov

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

  3. KC
    KC avatar
    14 posts
    Member since:
    Feb 2013

    Posted 03 Sep 2014 in reply to Martin Yankov Link to this post

    Hello Martin,

        I have taken over mobile development from Michael. I was able to fix this by changing all the 'div's to views from modal-views and adding an initial view to the The last one was the big one in order to get the navigation started.

    Thanks for the advice.

Back to Top