function checkConnection() {
var networkState = navigator.connection.type;
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.NONE] = 'No network connection';
alert(Connection.WIFI);
alert(navigator.connection.type);
alert('Connection type: ' + states[networkState]);
}
6975 次
2 に答える
6
deviceReady
イベント後に checkConnection を呼び出しましたか?
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
checkConnection();
}
checkConnection では、https://issues.apache.org/jira/browse/CB-1807 の代わりに使用するだけnavigator.network.connection.type
ですnavigator.connection.type
于 2012-11-28T14:15:05.520 に答える
5
これはcordova2.2.0のバグのようです
于 2012-11-08T11:41:17.050 に答える