Skip to content

Commit

Permalink
fix(android): isConnected is incorrect for wifi networks only the app…
Browse files Browse the repository at this point in the history
… has access to (#443 by @eliaslecomte)
  • Loading branch information
eliaslecomte committed Mar 3, 2021
1 parent 27043ef commit 7084771
Showing 1 changed file with 3 additions and 1 deletion.
Expand Up @@ -13,6 +13,7 @@
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.os.Build;

import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -39,7 +40,8 @@ public NetworkCallbackConnectivityReceiver(ReactApplicationContext reactContext)
@SuppressLint("MissingPermission")
void register() {
try {
getConnectivityManager().registerDefaultNetworkCallback(mNetworkCallback);
NetworkRequest.Builder builder = new NetworkRequest.Builder();
getConnectivityManager().registerNetworkCallback(builder.build(), mNetworkCallback);
} catch (SecurityException e) {
// TODO: Display a yellow box about this
}
Expand Down

0 comments on commit 7084771

Please sign in to comment.