Android上的Cordova-plugin-network-information有一个问题。即使有4G连接,有时,当我从后台恢复应用程序并用navigator.connection.type检查连接时,它会返回connection.type = NONE,但确实有互联网连接。如果我关闭并重新打开应用程序,它将返回connection.type = 4G。我使用cordova@7.1.0和cordova-android@6.4.0
发布于 2018-06-13 19:15:43
这是我目前用来解决这个问题的方法:
document.addEventListener("resume", function(){
navigator.connection.getInfo(function(type){
navigator.connection.type = type;
});
}, false);有关原因的解释,请参阅CB-14132。
发布于 2018-01-02 02:18:28
试着使用
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
if(navigator.onLine) {
alert("Internet Connect");
}else {
alert("No Internet");
}
}https://stackoverflow.com/questions/48024891
复制相似问题