Reputation: 39
I'm developing an android application using cordova , I want to quit the application when i click on the back button knowing that i'm using Inappbrowser, could someone help me??
Upvotes: 0
Views: 3995
Reputation: 306
Try this one:
document.addEventListener("deviceready", onDeviceReady, false);
if (navigator.userAgent.match("Android"))
{
document.addEventListener("backbutton", onBackKeyDown, true);
}
function onBackKeyDown(e)
{navigator.app.exitApp();}
Upvotes: 2
Reputation: 4073
Because of the android life cycle (how apps are managed, cached etc.) it is not recommended to close apps. The user should just minimize it. You can stop all background-threads using onPause() method, if you have any.
By force-closing you will drain some battery, because android has to reload everything instead of loading a cached version.
Upvotes: 0