I have the following problem, I have a method that verifies whether the device is connected to the internet or not
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
assert cm != null;
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting() && activeNetwork.getState() == NetworkInfo.State.CONNECTED;
return isConnected;
}
Only, when I am connected to a wifi, where it does not have internet, it returns true. That is, the method returns true if there is a connection and not specifically with the internet. Has anyone gone through this?