Software Archive
Read-only legacy content
17061 Discussions

How to close app in Intel XDK

Suresh_N_
Beginner
852 Views

I am newly comes to intel XDK application html 5 Development. When i am creating a new android app's in this application contains of  multiple page application, I am facing a new problem (ie) how will exit a app on button click now am using a code are listed below 

navigator.app.exitApp();

Its not working , if any one know give me correct solution,its very helpfull to me.

 

0 Kudos
8 Replies
PaulF_IntelCorp
Employee
852 Views

You are trying to use a function that is part of the Cordova subsystem. If you have a multiple-page app, you must initialize the Cordova subsystem with each new page that is loaded, this is very slow and very inefficient. You should develop your app as a single-page app if you want the underlying Cordova subsystem, including such functions, to work.

0 Kudos
Dani_Carla
Beginner
852 Views

navigator.app.exitApp();

This code closes the app... but it still appears in the list of applications running

0 Kudos
PaulF_IntelCorp
Employee
852 Views

That's not a list of "running" apps, but a list of "recently used apps." Android keeps an app in memory, even if it has exited and is no longer running, so that the app may be quickly restarted. It will remove apps from memory (and from that "recently used list") if it needs the space for other apps. So seeing an app in that list is not an indication that it is still running.

0 Kudos
Dani_Carla
Beginner
852 Views

Paul... very good explanation.

Tanks!

0 Kudos
Sachin_J_
Beginner
852 Views

When click back button on my app close the app using show pop up box on screen..there is not working properly

<script type="text/javascript">
document.addEventListener("exitButton", function(){
             intel.xdk.notification.alert(
                        'Do you want to quit',
                        onConfirmQuit,
                        'QUIT title App',
                        'OK,Cancel'  
                    );
            }, true);

    function onConfirmQuit(button){
       if(button == "2"){
        navigator.app.exitApp();
    }
}

</script>

this script not working my Android phone.

please how to solve this problem on intel xdk and android phone also.

 

0 Kudos
PaulF_IntelCorp
Employee
852 Views

Probably doesn't work because you may not have the retired intel.xdk.notification plugin in your system? Please use the standard Cordova plugins instead, the old Intel XDK plugins have been retired and are no longer supported. There is a "notification" plugin in the "core" Cordova plugins list that you can use as an alternative to intel.xdk.notifcation.

Also, see this SO post > http://stackoverflow.com/a/36047901/2914328 <

0 Kudos
Frungh_B_
Beginner
852 Views

Paul F. (Intel) wrote:

You are trying to use a function that is part of the Cordova subsystem. If you have a multiple-page app, you must initialize the Cordova subsystem with each new page that is loaded, this is very slow and very inefficient. You should develop your app as a single-page app if you want the underlying Cordova subsystem, including such functions, to work.

Hello Paul,

1. Can you give me a reference code (or link) in how to initialize the cordova subsystem with each new page that is loaded so that I can close my app?

2. If this process is very inefficient, what is the method I must use to close a multiple-page app using the back button?

 

0 Kudos
PaulF_IntelCorp
Employee
852 Views

If you are building a true multi-page app (multiple html files, each opened as a new "page" in the app), then you need to include a <script> reference to cordova.js in each of those pages. However, this will result in a restart of the underlying Cordova framework. This is not a recommended approach for building Cordova apps (see this Cordova Next Steps article for lots of useful information). I highly recommend that you implement an SPA, as described by the referenced article.

There is no need to close your app using the back button, all the user has to do is "switch away" from the app. If you want to force what the backbutton does, you can trap the event. See this Cordova doc page and search for "backbutton" on the page. You could try using the poorly documented navigator.app.exitApp() function in response to the backbutton event, but I do not know if that function continues to be supported by the most recent versions of Cordova.

0 Kudos
Reply