Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5080] Android: Titanium.Network.addEventListener does not fire after creating new tabgroup

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-01-29T00:00:52.000+0000
Affected Version/sRelease 1.7.2, Release 2.1.0
Fix Version/sRelease 3.2.0
ComponentsAndroid
Labelscore, module_network, qe-closed-3.2.3, qe-manualtest, supportTeam
ReporterFrancisco Antonio Duran Ramirez
AssigneeIngo Muschenetz
Created2011-08-22T16:04:47.000+0000
Updated2014-08-07T21:50:02.000+0000

Description

Bug

Problem:

Titanium.Network.addEventListener does not fire after creating new tabgroup.

Reproducible steps:

1.Run the code below. 2.Without clicking on 'Log In' button please change the network status on your Android device - the Titanium.Network event should be fired 3.Click on the 'Log In' button, after that new tabgroup will be created. 4.Change network status on your Android device - the event is no longer fired.

Expected behavior

Customer wants that the Titanium.Network.addEventListener would be a global listener (that would appear only once in the code). That should be the correct behaviour.

Sample Code:


var tabGroup = Titanium.UI.createTabGroup();

var win0 = Titanium.UI.createWindow();

var btnLogin = Titanium.UI.createButton({
	title:'Log In',
	color:'Black',
	left:50,
	height:30,
	right:50
});
win0.add(btnLogin);

var tab0 = Titanium.UI.createTab({ 
    title:'Log In',
    window:win0
});

tabGroup.addTab(tab0);   
tabGroup.open();

function BuildTabGroup(ActiveTabIndex){
	// create tab group
	var tabGroup2 = Titanium.UI.createTabGroup();
	var mainWin= Titanium.UI.createWindow();
	var tab0 = Titanium.UI.createTab({
	    window:mainWin
	});
	tabGroup2.addTab(tab0);  
	tabGroup2.open();
}

if (!Titanium.Network.online) {
	var noNetworkAlert = Titanium.UI.createAlertDialog({
		title: 'Network Error',
		message: "You do not appear to have network connectivity.  You will need an internet connection to use this application.",
		buttonNames: ['OK']
	});
	noNetworkAlert.show();
}

Titanium.Network.addEventListener('change', function(e){
	var online = e.online;
	if (online) {
		alert("Network connection re-established.  You are now using your " + Titanium.Network.networkTypeName + " internet connection.");
	}
	else {
		alert("Your network connectivity has been lost.  Check your device settings.");
	}
});

btnLogin.addEventListener('click',function(){
	var tbg = Titanium.UI.currentTabGroup;
	tbg.close();
	tbg = null;
	BuildTabGroup(0);
});

HelpDesk.

APP-287557

Attachments

FileDateSize
app.js2011-08-22T16:04:47.000+00001355

Comments

  1. MAIRDUMONT GmbH & Co. KG 2012-07-05

    Wonder when this will be resolved? Is there any other workaround than checking any x sec if Ti.Network.online has changed?
  2. Junaid Younus 2012-07-12

    Tested on a Samsung Galaxy S2 with 2.1GA. First time I open the app, it gives me an alert. I change the network status of the device and press the log in button. It comes up with a runtime error saying "Uncaught TypeError: Cannot call method 'close' of undefined. Source: tag.close();" No network changed event seems to be firing.
  3. Shak Hossain 2014-01-29

    Resolving this as per updated test results. We tested the issue with TISDK 3.2GA and we could not reproduce it.
  4. Paras Mishra 2014-03-12

    Titanium.Network.addEventListener is working as expected. Verified the fix using: Device : Google Nexus 4, Android Version: 4.1.1 SDK: 3.2.3.v20140311115447 CLI version : 3.2.1 OS : MAC OSX 10.9 Alloy: 1.3.1 ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.2.2.201403061827 titanium-code-processor: 1.1.0 XCode : 5.1

JSON Source