exit throught javascript code from android app (Intel XDK crosswalk android build)
-
23-12-2019 - |
Question
I'm creating javascript app for android Intel xdk crosswalk for android build.
I'm unable to exit from my app using following commands:
navigator.app.exitApp();
and
navigator.device.exitApp();
How to close an app?
Solution
The code below works for me. You need the cordova.js script tag. The intel xdk inserts the cordova.js when it builds the app, you don't need to put the actual file in your project directory.
Exitapp had a bug that is fixed in Crosswalk 4.32.76.3. If you are launching the app from the debug tab, then it will be using an older crosswalk that does not work. You can use the newer crosswalk by building the app, and in the bottom of the details page select the canary option which is labeled Crosswalk 4.32.76.4
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript"">
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, true);
}
function exitFromApp()
{
navigator.app.exitApp();
}
</script>
</head>
<body onload="onLoad();">
<button name="buttonClick" onclick="exitFromApp()">Click Me!</button>
</body>
</html>
OTHER TIPS
Make sure you've included cordova.js after intelxdk.js -- and note that this exit function only works on Android, it will not work with iOS.