Skip to content

Commit

Permalink
catch null pointer exception in network test
Browse files Browse the repository at this point in the history
  • Loading branch information
triestpa committed Feb 9, 2014
1 parent 61de89e commit df70236
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/edu/grinnell/glicious/menucontent/GetMenuTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,18 @@ protected static boolean networkEnabled(ConnectivityManager connec) {
return false;
}

if (connec.getNetworkInfo(1) != null
&& connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED)
return true;
else if (connec.getNetworkInfo(0) != null
&& connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED)
return true;
else
try {
if (connec.getNetworkInfo(1) != null
&& connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED)
return true;
else if (connec.getNetworkInfo(0) != null
&& connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED)
return true;
else
return false;
} catch (NullPointerException exception) {
return false;
}
}

/* Return true if the appropriate host can be reached. */
Expand Down

0 comments on commit df70236

Please sign in to comment.