我正在使用 phonegap 开发应用程序。在我的应用程序中,我需要检查网络状态。我使用了以下代码,
function checkConnection()
{
var networkState = navigator.network.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';
console.log("network------"+networkState);
return networkState;
}
它工作正常,但离线模式也返回 3g(在模拟器中测试)。y'day 也工作正常。此方法有任何问题请指导我...