Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Suresh_N_
Beginner
170 Views

How to close app in Intel XDK

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.

 

Tags (2)
0 Kudos
8 Replies
PaulF_IntelCorp
Employee
170 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.

Dani_Carla
Beginner
170 Views

navigator.app.exitApp();

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

PaulF_IntelCorp
Employee
170 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.

Dani_Carla
Beginner
170 Views

Paul... very good explanation.

Tanks!

Sachin_J_
Beginner
170 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.

 

PaulF_IntelCorp
Employee
170 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 <

Frungh_B_
Beginner
170 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?

 

PaulF_IntelCorp
Employee
170 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.

Reply