Skip to content Skip to sidebar Skip to footer

Is It Really Posible To Close A PhoneGap App?

I have searched all over the web and found different ways of closing a PhoneGap App. I tested all of them and none work. At least on Android. Question: Is it possible (By Feb 2014)

Solution 1:

Is

navigator.app.exitApp() 

really killing/closing the android app with phonegap?

I use cordova and have the same issue. Above mentioned code is just putting the app into background - I checked the running tasks (android task manager) after above code got executed by the app.


Solution 2:

I am confused on why you want a button to close the app. Android already has a back button when clicked enough times will take the user back to the phone's main screen. There is also a home button that takes the user out of an app. Once, out of the app the user can "kill" the app through a task manager.


Solution 3:

navigator.app.exitApp() 

works and I use it in all my cordova apps. Check the rest of your code.

As ejwill said, having a "close" button is a bad idea. On Android I call exitApp when the user is the home page of my app and he presses the backbutton:

function onDeviceReady() {
    document.addEventListener("backbutton", onBackKey, false);
}


function onBackKey( event ) {
    var l = window.location.toString();
    var parts = l.split('#/');  // this works only if you are using angularjs
    var page = parts[1];
    if (page == 'home') {
        navigator.app.exitApp();
    } else {
        // do something else... one option is:
        navigator.app.backHistory();
    }
}

My 2c.


Post a Comment for "Is It Really Posible To Close A PhoneGap App?"