Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2778] Android: window open events are not firing when windows belong to tabs

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2012-03-28T16:05:12.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterShannon Hicks
AssigneeMauro Parra-Miranda
Created2012-03-21T12:53:17.000+0000
Updated2016-03-08T07:47:41.000+0000

Description

The open event is not firing reliably. Here's a summary of what happens on each platform: iOS: win1 open event fires when the app opens, win2 open event fires when you switch to it's tab Android Ti 1.8.1: no open events fire Android Ti 1.8.2: no open events fire Android Ti 2.0 CI: win1 open event fires when the app opens, win2 open event never fires
// 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();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
win1.addEventListener('open',function(){
	alert('win1 opened');
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});

var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 1',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
win2.addEventListener('open',function(){
	alert('win2 opened'); // this event does not fire on Android
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});

var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win2.add(label2);



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


// open tab group
tabGroup.open();

Comments

  1. Mark Ruys 2012-03-23

    I experience the same problematic behavior. Work around is to capture the windows focus event and use a boolean to make sure your code is run only once.
  2. Shannon Hicks 2012-03-23

  3. Mauro Parra-Miranda 2012-03-28

  4. Mauro Parra-Miranda 2013-11-24

    Closing since it's a dup.

JSON Source