I have following method, which will check for the Internet connection in the device :
public static boolean checkInternetConnection(Context context) {
ConnectivityManager connectivityManager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager.getActiveNetworkInfo() != null
&& connectivityManager.getActiveNetworkInfo().isAvailable()
&& connectivityManager.getActiveNetworkInfo().isConnected()) {
return true;
} else {
return false;
}
}
But after a while I found out that this method only checks for the Network Connectivity; like the device is connected to a router and the router is ON but no internet is available, this method returns true.
So How to know that there is actual internet or not ?