Skip to content

Commit

Permalink
Issue #16 fix : Fixed crash related to active network info.
Browse files Browse the repository at this point in the history
  • Loading branch information
RandhirGupta committed Apr 10, 2018
1 parent 4ba8c01 commit 9258aea
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.ekstep.ipa.ui.addchild.AddChildActivity;
import org.ekstep.ipa.ui.landing.geniechildren.GenieChildrenFragment;

import static android.net.NetworkInfo.State.CONNECTED;

/**
* @author vinayagasundar
*/
Expand Down Expand Up @@ -175,7 +173,8 @@ private void goToNetworkSettingScreen() {
}

public boolean isEnabled() {
return ((mConnectivityManager != null) ? mConnectivityManager.getNetworkInfo(0).getState() : 0) == CONNECTED;
return (((mConnectivityManager != null) && mConnectivityManager.getActiveNetworkInfo() != null) ?
mConnectivityManager.getActiveNetworkInfo().getType() : 0) == ConnectivityManager.TYPE_MOBILE;
}

private boolean isConnectedToOpenRAPNetwork(String ssid) {
Expand All @@ -186,10 +185,8 @@ private boolean isConnectedToOpenRAPNetwork(String ssid) {
if (wifiInfo != null) {
NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
String currentSsid = wifiInfo.getSSID();
if (currentSsid.equals(String.format("\"%s\"", ssid)) &&
(state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR)) {
return true;
}
return currentSsid.equals(String.format("\"%s\"", ssid)) &&
(state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR);
}
}
return false;
Expand Down

0 comments on commit 9258aea

Please sign in to comment.