I am using this code to check the connection in my app :
ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
this method will return "true" even the device just connect to wifi and not has a connection to the internet or the device turn on mobile network but run out of data. I have read many posts, but most of them are too old. I dont know those answers are still right or not. So, how to check if the device has a "real" connection to the internet ?
This maybe a similar question : Android: Check network and real internet connectivity