Software Archive
Read-only legacy content
17061 Discussions

exit program

zeroman_z_
Beginner
431 Views

i need code to exit program plz

0 Kudos
5 Replies
PaulF_IntelCorp
Employee
431 Views

See this post, I think it is what you are looking for: https://software.intel.com/en-us/forums/intel-xdk/topic/593293

0 Kudos
Matrix_Lee
Beginner
431 Views

This method will exit but the App will still in background.

It there any way to fully exit app even not in background?

I found a reference like this.

http://stackoverflow.com/questions/36129144/how-to-fully-exit-android-application-in-phonegap

I change the code in CoreAndroid.java but it is still in background.

Please help.

Thank.

Matrix

0 Kudos
Anusha_M_Intel1
Employee
431 Views

I was going to suggest killing the app programmatically but that is not good practice and might risk your app getting rejected by the store. 

I don't think there is a way to exit the app from running in the background. Maybe you can try disabling the javascript from running when the app is in the background. Try this thread: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/8_XUXo0yOWQ

It has a few suggestions.

0 Kudos
Matrix_Lee
Beginner
431 Views

Thank you for replying.

Yes, normally it is not.

But after a lot of trying, I found the way to exit from background.
Add a window.close() can solve this problem.

I made a exitAppFromBackground() function for it.
The source code as below for your further test and reference.

// Name: exitFromBackground()
// Author: Matrix Lee
// Function: Exit app, and remove it from the background.
function exitAppFromBackground(){
    window.close();
    if(navigator.app){
        navigator.app.exitApp();
    }else if(navigator.device){
        navigator.device.exitApp();
    }
}

Matrix

 

0 Kudos
Hamilton_Tenório_da_
Valued Contributor I
431 Views

I have used this command to exit:

navigator.app.exitApp();

But... just to Android. As far as I know, Apple do not permit this. In my apps, when running under iOS, I hidden the button EXIT.

0 Kudos
Reply