I have the following code:
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
String estado=networkInfo.getState().toString();
Log.i("conexion",estado);
if (networkInfo != null && networkInfo.isConnected()) {
// Operaciones http
new LeerDeInternet().execute("http://www.floatrates.com/daily/ars.json");
} else {
Toast.makeText(this, "Compruebe su conexión a internet",Toast.LENGTH_SHORT).show();
}
The problem is that although I do not have wifi and data network signal does not work (!) it returns the CONNECTED status and therefore the process is executed and waiting for data. The only way to tell me to check the connection is to disconnect the mobile network.