This commit is contained in:
PavelRatushny 2017-08-30 14:51:28 +03:00
parent d3a3d51a24
commit 3e86975ecf

View file

@ -256,12 +256,17 @@ public class OsmandSettings {
}
public boolean isWifiConnected() {
try {
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = mgr.getActiveNetworkInfo();
return ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI;
} catch (Exception e) {
return false;
}
}
private boolean isInternetConnected() {
try {
ConnectivityManager mgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo active = mgr.getActiveNetworkInfo();
if (active == null) {
@ -270,6 +275,9 @@ public class OsmandSettings {
NetworkInfo.State state = active.getState();
return state != NetworkInfo.State.DISCONNECTED && state != NetworkInfo.State.DISCONNECTING;
}
} catch (Exception e) {
return false;
}
}