Skip to content

Commit

Permalink
fix(android): avoid crash on devices without wifi (#662)
Browse files Browse the repository at this point in the history
* fix: crash on devices without wifi

Co-authored-by: Mike Hardy <github@mikehardy.net>
  • Loading branch information
g4rb4g3 and mikehardy committed Apr 6, 2023
1 parent 2c3c041 commit a519e59
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -142,7 +142,10 @@ protected WritableMap createConnectivityEventMap(@Nullable final String requeste

// Add if WiFi is ON or OFF
if (NetInfoUtils.isAccessWifiStatePermissionGranted(getReactContext())) {
boolean isEnabled = mWifiManager.isWifiEnabled();
boolean isEnabled = false;
if (mWifiManager != null) {
isEnabled = mWifiManager.isWifiEnabled();
}
event.putBoolean("isWifiEnabled", isEnabled);
}

Expand Down Expand Up @@ -208,7 +211,7 @@ private WritableMap createDetailsMap(@Nonnull String detailsInterface) {
}
break;
case "wifi":
if (NetInfoUtils.isAccessWifiStatePermissionGranted(getReactContext())) {
if (NetInfoUtils.isAccessWifiStatePermissionGranted(getReactContext()) && mWifiManager != null) {
WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
if (wifiInfo != null) {
// Get the SSID
Expand Down

0 comments on commit a519e59

Please sign in to comment.