0

So i just read this, about how closing an android app is "bad". What I don't understand is that would imply that the "exitonclose", ah, parameter? on a window doesn't really have a purpose for an android app.

I know that apple also discourage people from exiting an app, so it presumably doesn't have a purpose for iOs either.

So what is the point of the exitonclose then?

Community
  • 1
  • 1
bharal
  • 15,461
  • 36
  • 117
  • 195

1 Answers1

0

exitOnClose is a property of User Interface Window Class. This property will force close the window when the user tap over "back" button of Android Device and this window is opened.

Also, you can quit app with this code:

Ti.Android.currentActivity.finish();

For example (myWindow = UI.Window.createWindow ...):

var quitFunction = function quitFunction() {
    var dialog = Ti.UI.createAlertDialog({
        cancel : 1,
        buttonNames : ['Accept', 'Cancel'],
        message : 'Do you want exit?',
        title : 'Quit App'
    });
    dialog.addEventListener('click', function(e) {
        if (e.index === 0) {
           Ti.Android.currentActivity.finish();
        }
        dialog.hide();
        dialog = null;
    });
    dialog.show();
};
myWindow.addEventListener('android:back', quitFunction);

quitFunction can be changed with other purpose and you can control programatically its call.

iOS have not this phisical button, so we can not use this property for this.

  • ok, that's what exitonclose does... but what is the literal point of it, if closing apps on android is discouraged? What is the point of the finish() if closing apps on android is discouraged? – bharal Aug 20 '14 at 09:08
  • For example, in a game you may be interested to close the app to free memory or other functions like updates. If your application is not background, it is not required to close the application, but it would be suitable – Alejandro F. Carrera Aug 20 '14 at 09:23
  • but this is actively discouraged - the android os is meant to take care of this. In relation to the answer: http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon/2034238#2034238, how does this fit in? – bharal Aug 20 '14 at 09:30
  • Yes. Android and iOS manage this state, but you can manage manually if you want for any reason. exitOnClose property allow this. In the answer, as i said ("background or push notification"), it is important manage memory and state the application in this case for secure its use. – Alejandro F. Carrera Aug 20 '14 at 09:51
  • right, i get i "can" manage it, but the answer i linked to implies i should **not** be managing it. What security reason would i need to start shutting apps down? – bharal Aug 20 '14 at 09:53
  • In my opinion (from experience), when you have alocated too much memory and after there may be other processes so navigation may not be fluid (3D game), but its implementation would be a button or alert (dialog in the code) due to home button exist – Alejandro F. Carrera Aug 20 '14 at 10:15