Problem with Android When Press Back Button on FirstPage

2 posts, 0 answers
  1. Yılmaz
    Yılmaz avatar
    3 posts
    Member since:
    May 2015

    Posted 16 Sep 2015 Link to this post

    Hello,

     I am developing an app with Kendo Mobile js library and AppBuilder Windows Client.

    My problem is in my application when I press Back button on FirstPage it raises an exception instead of quitting app "Uncaught ReferenceError: start is not defined" , I am sharing my example code, I am trying it with Andy (emulator), Samsung Note 3 (Android 4.3 ) and Genymotion (Android 4.4.4), and behaves same on each environment.

     I can not find how to archive my project in appbuilder.

    Kendo UI Core v2015.2.813

     

    index.html

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
        <meta charset="utf-8" />
        <link href="kendo/styles/kendo.mobile.all.min.css" rel="stylesheet" />
     
        <script src="cordova.js"></script>
        <script src="kendo/js/jquery.min.js"></script>
        <script src="kendo/js/kendo.mobile.min.js"></script>
        <script src="app.js"></script>
         
    </head>
    <body>
         
            <div data-role="layout" data-id="main" >
                <div data-role="header">
                    <div data-role="navbar">
                        <span data-role="view-title"></span>
                        <button data-role="backbutton" data-align="left" data-click-on="down" >Back</button>
                         
                    </div>
                </div>
     
                <!-- application views will be rendered here -->
     
            </div>
    </body>
    </html>
     

    main.html

    <div data-role="view" data-title="Main Page" data-layout="main"  data-transition="overlay"  >
        First Page
        <button data-role="button" onclick="app.mobileApp.navigate('second.html');">Second Page</button>
      
    </div>

    app .js

    var app = {
        data:{}
    };
    document.addEventListener('deviceready', function () { 
            // hide the splash screen as soon as the app is ready. otherwise
            // Cordova will wait 5 very long seconds to do it for you.
            navigator.splashscreen.hide();
     
            app.mobileApp = new kendo.mobile.Application(document.body, {
             
                                                             // comment out the following line to get a UI which matches the look
                                                             // and feel of the operating system
                                                             skin: 'flat',
     
                                                             // the application needs to know which view to load first
                                                             initial: 'main.html',
                                                             transition:'slide'
                                                         });
    });
        window.onerror = function(msg, url, line, col, error) {
            // Note that col & error are new to the HTML 5 spec and may not be
            // supported in every browser.  It worked for me in Chrome.
            var extra = !col ? '' : '\ncolumn: ' + col;
            extra += !error ? '' : '\nerror: ' + error;
     
            // You can view the information in an alert to see things working like this:
            alert("Error: " + msg + "\nurl: " + url + "\nline: " + line + extra);
     
            // TODO: Report this error via ajax so you can keep track
            //       of what pages have JS issues
     
            var suppressErrorAlert = true;
            // If you return true, then error alerts (like in older versions of
            // Internet Explorer) will be suppressed.
            return suppressErrorAlert;
        };
     

     

    second.html

    <div data-role="view" data-title="Second Page" data-layout="main"  data-transition="overlay"  >
        Welcome to second Page!
    </div>

     

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 18 Sep 2015 Link to this post

    Hi Yilmaz,

    You can exit the application invoking navigator.app.exitApp().
    For example:

    <button data-role="button" data-align="left" onclick="navigator.app.exitApp()">Back 1</button>

    You can also write a more complicated logic in a function to serve the requirement you have.
    index.html:
    <button data-role="button" data-align="left" onclick="onButtonDown()">Back 2</button>

    app.js:
    // Handle the button
    function onButtonDown() {
        // Exit the app!
        alert("Exited!");
        navigator.app.exitApp();
    }

    You can also check the following resources: 
    Android back button forum;
    Exit Mobile App in PhoneGap post;

    As a side note, in regard to archiving a solution, please check the topic on Export  Your Project.
    I hope this helps.

    Regards,
    Dimitrina
    Telerik
     

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

     
Back to Top