Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9108] Android: Network change listener does not fire

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-11T03:57:22.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-13 Core
ComponentsAndroid
LabelsSupportTeam, core, module_network, qe-testadded, regression
ReporterDaniel
AssigneeMax Stepanov
Created2012-05-07T12:43:20.000+0000
Updated2014-03-13T17:45:14.000+0000

Description

I recently updated from Titanium SDK 1.7x to 1.8.2. The Network change listener does not work anymore. Ti.Network.addEventListener("change",function(e) { Titanium.API.debug("Network changed"); if (Titanium.Network.online) { Titanium.API.debug("Network is available"); } }); Under 1.7.5 the log messages are printed, in 1.8.2 (and the most recent 1.8.3) it stopped working. I'm testing on an HTC Disre HD with Android 2.3.5. I was able to recreate it with above code added to the simplest test application

Attachments

FileDateSize
app.js2012-05-07T12:43:20.000+00001416
log.rtf2012-06-19T17:28:16.000+0000491921

Comments

  1. Alberto Berti 2012-05-25

    i have the same issue
  2. Josh Roesslein 2012-06-18

    Sent [PR #2423](https://github.com/appcelerator/titanium_mobile/pull/2423) to resolve issue.
  3. Eric Merriman 2012-06-19

    With SDK 2.1.0.v20120618154152, I was unable to get the event to fire. I tried on two devices (one without cell capability) and saw many indications in the log of the network change, but not the target text from the sample code. See attached log.
  4. Josh Roesslein 2012-06-20

    Eric, I was able to test this fine by turning the wifi on the device on/off. The device also had no cellular network capabilities. Could you provide steps to reproduce the failure you saw on this ticket? I know you talked about it yesterday, but if you could refresh my memory and also keep a record here for others.
  5. Satoshi Tanaka 2012-06-20

    I tested my Android, network change event fired correctly. But Ti.Network.NETWORK_WIFI is null, so below code doesn't work. Ti.Network.addEventListener('change', function(e) { if(Ti.Network.networkType == Ti.Network.NETWORK_WIFI) { Ti.API.info("Network changed to Wi-Fi!"); } });
  6. Josh Roesslein 2012-06-20

    Satoshi, could you please open a new issue for that property being null. I imagine the other NETWORK_ constants are null as well.
  7. Satoshi Tanaka 2012-06-20

  8. Eric Merriman 2012-06-22

    @Josh, just following-up from our conversation. Seems as though when I disabled the access point, the device switched to another access point. This may have prevented the listener from firing. I will attempt to verify this ticket again tomorrow.
  9. Max Stepanov 2012-06-26

    Cannot reproduce on GalaxyTab with 2.1.0 RC
  10. Max Stepanov 2012-06-26

    Fixed by PR https://github.com/appcelerator/titanium_mobile/pull/2423
  11. Eric Merriman 2012-06-26

    Verified fixed with SDK 2.1.0.v20120626130259 using the following code:
        var win = Ti.UI.createWindow({
            backgroundColor: '#ccc'
        });
         
        var table = Ti.UI.createTableView();
         
        win.add(table);
         
        var data = [];
        for(var i = 0; i < 50; i++){
            data.push({ title:'Row #'+i });
        }
        table.setData(data);
         
        win.open();
        
        Ti.Network.addEventListener("change",function(e) {
        Titanium.API.debug("Network changed");
        setTimeout(function() {
        alert("Network changed (available="+Titanium.Network.online+")");
        },100);
        if (Titanium.Network.online) { Titanium.API.debug("Network is available"); }
        });
        
  12. Shyam Bhadauria 2012-07-11

    Re-opening to edit label
  13. jithinpv 2013-11-25

    Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5011

JSON Source