Javanie
> Hi, try use browser exec JS and insert this code:
>
>
> > window.navigator.app.exitApp();
>
> or
>
> navigator.app.exitApp();
>
The Browser plugin's Close action already does that.
I don't know if browser plugin's close action already does that, thanks for the information.
piranha305
Since you asking "for is there a different way to provide a close application on android?"
and my first post is same as Browser plugin's close action navigator.app.exitApp(); then you can try the different way to close app on android below.
If you want to try different method close the app,navigator.app.exitApp(); is close app programmatically maybe you want to try force stop app programmatically.
You can export your project to android project then open CoreAndroid.java inside folder:
your cordova project folder\platforms\android\CordovaLib\src\org\apache\cordova
or if you export to cordova project then after cordova prepare go to folder:
your cordova project folder\platforms\android\CordovaLib\src\org\apache\cordova
search for:
else if (action.equals("exitApp")) {
this.exitApp();
}
else if (action.equals("exitApp")) {
// this.exitApp();
cordova.getActivity().finishAffinity();
System.exit(0);
}
This will quit the app completely.
You also can use this one, this will quit the app completely and remove from the recent tasks list:
else if (action.equals("exitApp")) {
// this.exitApp();
cordova.getActivity().finishAndRemoveTask();
System.exit(0);
}
Note:
.finishAndRemoveTask(); if you use this you will need at least minimum API 21.
If you use cordova.getActivity().finishAffinity(); or cordova.getActivity().finishAndRemoveTask(); without System.exit(0);
app will quit but the allocated memory will still be in use by device then use System.exit(0); to completely clean allocated memory in use by your app then quit the app completely.
To close app, just use browser close action this will execute cordova.getActivity().finishAffinity(); and System.exit(0);
or if you use quit the app completely and remove from the recent tasks list will execute
cordova.getActivity().finishAndRemoveTask(); and System.exit(0);
Demo video: