Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-982] Ti.App.addEventListener('close') not working

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:52.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.4.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:40:42.000+0000
Updated2011-04-17T01:54:52.000+0000

Description

code:

// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000');

// create tab group var tabGroup = Titanium.UI.createTabGroup();

Titanium.App.addEventListener('close',function(e)
{

alert("The application is being shutdown");

});

// // create base UI tab and root window // var win1 = Titanium.UI.createWindow({

title:'Tab 1',
backgroundColor:'#fff',
barColor:'#005298'

});

var tab1 = Titanium.UI.createTab({

icon:'KS_nav_views.png',
title:'Tab 1',
window:win1

});

var navbar = Titanium.UI.createTabbedBar({

labels:["A", "B"],
style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
backgroundColor:"#005298"

});

win1.setTitleControl(navbar);

var scrollView = Titanium.UI.createScrollView({

contentHeight: 'auto',
contentWidth:'auto',
top:0,
showVerticalScrollIndicator:true,
showHorizontalScrollIndicator:true

});

var view = Titanium.UI.createView({

width:300,
height:100,
top:20,
borderRadius:5,
backgroundGradient:{
    type:'linear',
    colors:[{color:'#005298',position:0.0},
                    {color:'#001d36',position:1.0}]

}

});

scrollView.add(view);
win1.add(scrollView);

// // add tabs // tabGroup.addTab(tab1);

// open tab group tabGroup.open();

Comments

  1. Stephen Tramer 2011-04-15

    This is a little misleading: The callback happens, but only after the program has suspended, which means that nothing is going to get logged. Seems like this will mostly end up being a documentation issue, provided that I can confirm that the stuff in the callback is actually happening (probably via a contacts or iPod test app).

    Once this is taken care of there will need to be some additional infrastructure for 4.0's pause/resume.

  2. Stephen Tramer 2011-04-15

    Okay, much worse than I thought. There's a race between Titanium and the OS to see when resources get freed up: The system wants to release them immediately, and Titanium wants to try and finish everything up. 4.0 allows for the application to demand additional time to finish tasks in the background, but allowing compilation for 3.1.x (and iPad) means that app event support wouldn't work on these systems.

    Investigating further.

  3. Dasher 2011-04-15

    Just so it doesn't slip through the cracks - this is also an issue on Android :)

  4. Blain Hamon 2011-04-15

    Tag team coding. Swapping with Steve.

  5. Jeff Haynie 2011-04-15

    (from [f6e6787856b1faf7e7b71cd577b775544b25d0ee]) When closing, the app now sends the close event before the rest of the shutdown, and waits for the function to be processed before exiting. Note that it does mean if the javascript takes too long, the app will be force quit like the iPhone OS would any other app. Closes #982 http://github.com/appcelerator/titanium_mobile/commit/f6e6787856b1faf7e7b71cd577b775544b25d0ee"> http://github.com/appcelerator/titanium_mobile/commit/f6e6787856b1f...

JSON Source