I copied that from another post:
public static boolean isOffline(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo == null || !netInfo.isConnected(); // netInfo.isConnectedOrConnecting()
}
If the screen is on and I'm using the device it works correct. But sometimes if the device is sleeping it returns that the device is offline.
I have a broadcast wich calls the same method later - then it is working (during a bug it is currently right afterwards).
Any ideas?