Merge pull request #4365 from osmandapp/dead_system_exception
Fix #4332
This commit is contained in:
commit
16a1599bf3
1 changed files with 17 additions and 9 deletions
|
@ -256,12 +256,17 @@ public class OsmandSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWifiConnected() {
|
public boolean isWifiConnected() {
|
||||||
|
try {
|
||||||
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo ni = mgr.getActiveNetworkInfo();
|
NetworkInfo ni = mgr.getActiveNetworkInfo();
|
||||||
return ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI;
|
return ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInternetConnected() {
|
private boolean isInternetConnected() {
|
||||||
|
try {
|
||||||
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo active = mgr.getActiveNetworkInfo();
|
NetworkInfo active = mgr.getActiveNetworkInfo();
|
||||||
if (active == null) {
|
if (active == null) {
|
||||||
|
@ -270,6 +275,9 @@ public class OsmandSettings {
|
||||||
NetworkInfo.State state = active.getState();
|
NetworkInfo.State state = active.getState();
|
||||||
return state != NetworkInfo.State.DISCONNECTED && state != NetworkInfo.State.DISCONNECTING;
|
return state != NetworkInfo.State.DISCONNECTED && state != NetworkInfo.State.DISCONNECTING;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue