Skip to content
This repository has been archived by the owner on Feb 7, 2021. It is now read-only.

Commit

Permalink
fixed a NPE
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/svnroot-zephyrsoft/projects/checknetwork/trunk@188 f37aa4ac-6963-46a2-a1ff-558a307fa857
  • Loading branch information
mathisdt committed Mar 3, 2013
1 parent 9cdbafe commit 2ab46eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/org/zephyrsoft/checknetwork/ConnectivityChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ protected Void doInBackground(Void... params) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
String networkType = "unknown";
if (netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
networkType = "wifi";
} else if (netInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
} else if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
networkType = "mobile data";
}
boolean connectionOK = (netInfo != null && netInfo.isConnected());
Expand Down Expand Up @@ -78,7 +78,7 @@ protected Void doInBackground(Void... params) {

private void tryToReconnect(Context context, ConnectivityManager cm) {
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
Logger.info("toggling wifi connection");
setWifiEnabled(context, false);
try {
Expand Down

0 comments on commit 2ab46eb

Please sign in to comment.