From 60ab69fe58fee52c8dae44e0cc00b2f4b6e239bd Mon Sep 17 00:00:00 2001 From: PVPoyer Date: Tue, 6 Nov 2018 10:34:50 +0100 Subject: [PATCH] Try to fix: https://github.com/apache/cordova-plugin-network-information/issues/64: working with the ConnectivityManager.NetworkCallback in case of Lollipop and above, but switching to unknown if type none in the onavailable callback. --- src/android/NetworkManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/android/NetworkManager.java b/src/android/NetworkManager.java index 7c612c9..db50de7 100755 --- a/src/android/NetworkManager.java +++ b/src/android/NetworkManager.java @@ -175,12 +175,24 @@ public class NetworkManager extends CordovaPlugin { @Override public void onAvailable(Network network) { + LOG.d(LOG_TAG, "In the on available: "); updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo()); + + String connectionType = determineCurrentConnectionType(); + + if(TYPE_NONE.equals(connectionType)) { + LOG.d(LOG_TAG, "ConnectionType none but in the onAvailable"); + LOG.d(LOG_TAG, "!!! Switching to unknown, onAvailable states there is a connectivity."); + sendUpdate(TYPE_UNKNOWN); + } + LOG.d(LOG_TAG, "End the on available: "); } @Override public void onLost(Network network) { + LOG.d(LOG_TAG, "In the on lost: "); updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo()); + LOG.d(LOG_TAG, "End the on lost: "); } }; sockMan.registerNetworkCallback(builder.build(), lollipopAndAboveNetworkCallback);