Imen.Ab
Imen.Ab

Reputation: 39

How to quit (exit) cordova (android) application when you click on the back button from Inappbrowser?

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

Answers (2)

Shanmugapriya D
Shanmugapriya D

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

KYL3R
KYL3R

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

Related Questions