0

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??

Imen.Ab
  • 39
  • 2
  • 12

2 Answers2

2

Try this one:

document.addEventListener("deviceready", onDeviceReady, false);


if (navigator.userAgent.match("Android"))
{
    document.addEventListener("backbutton", onBackKeyDown, true);
}
function onBackKeyDown(e) 
{navigator.app.exitApp();}
Shanmugapriya D
  • 306
  • 3
  • 13
0

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.

KYL3R
  • 3,877
  • 1
  • 12
  • 26