Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

[mobile] close application

I'm using Titanium.Network to detect if the user is online and if he is using MOBILE network, i'm displaying a warning dialog with two buttons: continue and exit.

How can i close the application when the user choose to exit?

I tried to close the only window i have created but the app still remains open and Titanium.App has no close or exit method.

Is it possible? Any tips?

Thank you

— asked May 10th 2010 by Catalin C.
  • android
  • close
  • mobile

12 Answers

  • Titanium does not currently have an explicit exit method. In Android applications, users normally just hit the back button to exit an application.

    — answered May 10th 2010 by Don Thorp
    1 Comment
    • I think so too but in docs about it not exist. Anyone can give me doc?

      — commented January 24th 2012 by NaneNare Hambardzumyan
  • @Don Throp> not true.

    A bad example is Opera Mini. You follow 10 links so you have to press back button countless times to exit.

    Also, with Titanium, what if we have a stack of 5 windows?
    We have, again, to press the back button quite a few times.

    So, as i said, android apps have Exit option:
    Dolphin browser, Nimbuzz, etc. all have it…

    We need it too.

    In my case, how can i, at least, close the main window when the user decides that he doesn't want to continue?

    — answered May 11th 2010 by Catalin C.
  • I'll add more data. Firstly none of the Google applications provide an Exit button. So there is a de-facto standard. Here is a good article on When to Include an Exit Button in Android Apps (Hint: Never).

    If your application is not visible, then it should be in a stopped state not consuming CPU. If Android decides it needs more resources it has the option to kill any/all processes. If you're app is stopped, it may not even have a process at that point it time. It's basically serialized and inactive.

    Depending on the device, your application can never take more than its 16-24MB allotted RAM (currently). Killing it doesn't actually free up more RAM for other processes. The Android OS will simply dump your app if it's stopped and reclaim the RAM.

    The user also has the option to simply switch to another app or press the home button. If they really want it killed, on 2.X devices they can use application settings to kill the app. Which is a last ditch effort to kill badly written applications.

    All that said, we'll look into an exiting option. But, from an Android standpoint and the tenants that the OS developers and Google App developers work under, there shouldn't be an exit button.

    — answered June 13th 2010 by Don Thorp
    1 Comment
    • OK, but how do we write "good" apps when Ti.App pause/resume events don't work on Android?

      — commented October 26th 2010 by Vitaly Kravchenko
  • Find a bug that crashes the app ;)

    — answered August 14th 2010 by Sj Singh
    1 Comment
    • No, find one that does not first :)

      — commented December 11th 2011 by Esben Maaløe
  • But on android that does not work either.
    It is still running in the background. We just got an android and the Verizon rep actually recommended an app that will display all the apps that are running that it can kill them.

    — answered May 10th 2010 by Stan Thompson
  • This would be a useful (and basic) feature, I think. Few apps let you quit them, but it's still a nice feature.

    Also being able to vote for and help prioritize features would be an awesome way to increase community involvement…

    — answered June 12th 2010 by Max Aller
  • Don, any progress on the exit method. That'd be very useful for me too.



    Hot Sauce Studios

    — answered August 3rd 2010 by Alex Sartogo
  • I'm going to resurrect this thread, as an application exit method would be very useful. There certainly is precedence for having one, Google Navigation itself has a Exit Navigation button in the bottom menu which exits the app!

    — answered May 27th 2011 by Justin Toth
  • Well, at least one case when exit would be very usefull:

    I write this code to clean built-in remote images cache on sd-card

    var dir = Titanium.Filesystem.getFile(Titanium.Filesystem.externalStorageDirectory); 
    var cache_folder = dir.nativePath.toString()+'/remote-image-cache';
    var deldir = Titanium.Filesystem.getFile(cache_folder); 

    it works, but if I exit app with back button or with

    var activity = Titanium.Android.currentActivity;

    At the next restart all images in my tableview is broken (empty)

    I have to kill app with external method to have all works fine again.

    So, having a kill method would solve my problem (I can't instruct my user to kill app with external program or restarting phone at all)

    — answered October 29th 2011 by massimo.morselli@gmail.com massimo.morselli@gmail.com
  • seems that Titanium fails if dir remote-image-cache isn't found, so a deldir.createDirectory(); after deldir.deleteDirectory(true); can be a workaround.

    Exits app isn't really necessary anymore.

    — answered November 13th 2011 by massimo.morselli@gmail.com massimo.morselli@gmail.com
  • My application is closed and navigate to home screen using setting both [exitOnClose:true; OR Titanium.Android.currentActivity.finish();] but at settings->manage application->running it showing my application icon running list at back end so how to resolve this issue?I want when my application is gets closed at a time i want to stop back end running process also.please help me out.

    — answered November 19th 2011 by Fernan Delgado
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.