My app works in offline mode also and it works fine when internet is available. I am using the following code to check internet connection.
ConnectivityManagercm = (ConnectivityManager) ConnectivityClass.getInstance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
Problem is if we connected WiFi network that doesn't include internet access or requires browser-based authentication it still returns true. It should returns false if internet is not available. I need to check internet connection rather than mobile network connection status.
minSdkVersion 15
You can ping URL. Then u can know the internet is exactly available.