Reputation: 92
I'm using volley framework for network requests in android. What error code will I get for No internet connection. There is an volley error class name NoConnectionError
which says this, but if the url is not valid (and internet connection exists) the same error is returned. Is there any other way to check the internet state in volley ?
Upvotes: 1
Views: 1567
Reputation: 1228
Why don't you create method that checks if DATA of WIFI connection exist then execute the request like :
public static boolean isConnected(Context context){
NetworkInfo localNetworkInfo = ((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (localNetworkInfo == null) {
return false;
}
else{
//Check if only wifi is selected or wifi==1 Constant Value: 1 (0x00000001)
if(((localNetworkInfo.getType() == 1)) || (localNetworkInfo.isConnected()) || (localNetworkInfo.isAvailable()))
return true;
}
return false;
}
Upvotes: 1