Android: navigator.connection.type returns 0 (phonegap 2.2.0)

566 views
Skip to first unread message

Gwendolyn

unread,
Nov 7, 2012, 6:48:02 AM11/7/12
to phon...@googlegroups.com
Hi all,

I upgraded to phonegap 2.2.0, changed (as documented) navigator.network.connection.type to navigator.connection.type and this is the result:

var networkState = navigator.connection.type;

alert("Connection: " + navigator.connection); // result: Object Connection

alert("networkState: " + navigator.connection.type); // result: 0

var states = {};

    

states[Connection.UNKNOWN]  = 'bad';

states[Connection.ETHERNET] = 'wifi';

states[Connection.WIFI]     = 'wifi';

states[Connection.CELL_2G]  = 'cell';

states[Connection.CELL_3G]  = 'cell';

states[Connection.CELL_4G]  = 'cell';

states[Connection.NONE]     = 'bad';


return states[networkState];


While it should say "wifi", I get 0 as result of navigator.connection.type.


I'm testing on a Samsung Galaxy S3. 


Any ideas?

Simon MacDonald

unread,
Nov 7, 2012, 7:50:26 AM11/7/12
to phonegap
There is an open JIRA issue on this. For the mean time continue to use navigator.network.connection.type.

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
 
 

Gwendolyn

unread,
Nov 7, 2012, 8:14:41 AM11/7/12
to phon...@googlegroups.com
Thanks Simon!

I already tried using navigator.network.connection.type again but that results in an error: 
Uncaught TypeError: cannot read property "connection" of undefined at ...

Do you have any idea how I can fix this? 


Op woensdag 7 november 2012 13:51:03 UTC+1 schreef Simon het volgende:
Reply all
Reply to author
Forward
0 new messages