Created
June 21, 2019 17:09
-
-
Save afreakyelf/a2872430f07561b368775fdb673341a6 to your computer and use it in GitHub Desktop.
To check internet Connectivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean isOnline() { | |
ConnectivityManager cm = | |
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo netInfo = cm.getActiveNetworkInfo(); | |
if (netInfo != null && netInfo.isConnectedOrConnecting()) { | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment