Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6503] MobileWeb: Ti.Network.networkType always returns -1 with networkTypeName as UNKNOWN

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2012-02-13T16:46:35.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsMobileWeb
Labelsn/a
ReporterAnthony Decena
AssigneeChris Barber
Created2011-12-07T12:01:59.000+0000
Updated2014-01-28T23:57:35.000+0000

Description

Regardless of browser or device, the networkType always returns -1 and the networkTypeName returns UNKNOWN.
Ti.API.info('type:' + Titanium.Network.networkType);
Ti.API.info('online:' + Titanium.Network.online);
Ti.API.info('name:'+Titanium.Network.networkTypeName);

Comments

  1. Chris Barber 2011-12-08

    The reason it's -1 is because that's the value of the constant Ti.Network.NETWORK_UNKNOWN. Android 2.2+ is the only web browser that reports the connectivity information. For all other browsers, there's no way to accurately detect the network type. You could do a speed test downloading an image to best guess, but it's unreliable. To implement this for Android 2.2+, implement checks for navigator.connection.type. Refer to http://davidbcalhoun.com/2010/using-navigator-connection-android and http://stackoverflow.com/questions/4459029/is-there-a-way-to-detect-if-a-user-is-on-a-wifi-connection-with-php-or-javascrip.
  2. Anthony Decena 2011-12-10

    This actually already returns correctly for the Android web browser. Returning type = 3 and name = MOBILE for any Android 2.2+ browser.
  3. Chris Barber 2012-02-13

    This is a non-issue and works as expected.

JSON Source