Titanium Community Questions & Answer Archive

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

Global / App events list

Where can I find a list of all application level events, i.e. things like "application exits" and similar?
I would assume that there are such events, but I can't find documentation for them.

If there is no such list to link to, can someone please provide it in short form? I mean there must be some basic app level events like for startup and exit?

(Example for background: What if I'd like to implement some state saving functionality that executes when the app is about to exit?)

— asked July 23rd 2010 by Denis Andrejew
  • docs
  • documentation
  • event
  • events
  • state

5 Answers

  • Is there any conclusion on this topic? I've just hit it: I need to run some function when the app starts and when the app closes. I assume I should be able to catch these app-level events somehow. However, when I add the following lines I see that only 'pause' and 'resume' work:

    Titanium.App.addEventListener('open', function (e) {
        Ti.API.info('app.js: Open event on '+Ti.Platform.osname);
    Titanium.App.addEventListener('close', function (e) {
        Ti.API.info('app.js: Close event on '+Ti.Platform.osname);
    Titanium.App.addEventListener('pause', function (e) {
        Ti.API.info('app.js: Pause event on '+Ti.Platform.osname);
    Titanium.App.addEventListener('resume', function (e) {
        Ti.API.info('app.js: Resume event on '+Ti.Platform.osname);

    I see only pause and resume events are fired.

    — answered May 21st 2011 by Mikhail Gavryuchkov
    1 Comment
    • Yes, I've seen what you're describing.

      To have code run when app first starts, put it in app.js

      To have code run when the app closes, look at the Kitchen Sink and examine how it creates the alert, "The Kitchen Sink has been closed."

      — commented May 22nd 2011 by Robb Shecter
  • Hey, you have to put the open/close listeners on your main window…

    var main_window = Ti.UI.createWindow();
    main_window.addEventListener('open', function(e){ ... });
    — answered June 18th 2011 by Kelly Redd
  • You don't need the "open" event. Just put your code in app.js which is interpreted only once.

    — answered June 18th 2012 by Thibault HENRY
  • Events for each object is in the API documentation under the event section.

    For example, for mobile window object events see: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Window-object

    — answered August 3rd 2010 by Jim K
    1 Comment
    • Thanks, but unfortunately that's not what I'm asking about. I understand where to find the list of events that all kinds of classes / objects support. I've read in various places around the forums here that there should be "app level events" (for lack of a better term). Are you saying there are no such events?

      — commented August 3rd 2010 by Denis Andrejew
  • read this thread - first answer by Jeff.

    — answered August 3rd 2010 by Dan Tamas
    1 Comment
    • Which thread?

      — commented August 3rd 2010 by Denis Andrejew
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.