Reputation: 2079
I use Cordova 1.7.0, though tried with 1.6.1 and invoked all methods of full exiting app I found on the internet. But my android app always remains running in background. I use:
document.addEventListener("backbutton", function(e) {
if ($.mobile.activePage.attr('id') === 'homePage') {
navigator.app.exitApp();
} else {
window.history.back();
}
}, false);
Now, it exits fully on simulator, but never on the device. Is there a sure way to kill Phonegap app on exit in android?
Upvotes: 2
Views: 7056
Reputation: 61
look
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK,
function() {
if ($.mobile.activePage.attr('id') == 'page') {
blackberry.app.exit();
return false;
}
else {
history.back();
return false;
}
});
}
</script>
Upvotes: 0
Reputation: 1787
From the Javadoc:
// Enable app to keep running in background. (Boolean - default=true)
super.setBooleanProperty("keepRunning", false);
Update: forgot to mention that you need to add this line in the main activity class, which extends DroidGap, like this:
public class RSSDemoActivity extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setBooleanProperty("keepRunning", false);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Upvotes: 7