Created
January 4, 2016 15:06
-
-
Save 3ffusi0on/dd01a0bbd1f371441a7c to your computer and use it in GitHub Desktop.
Android function to check network availability
This file contains hidden or 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
private Boolean isNetworkAvailable() { | |
ConnectivityManager connectivityManager | |
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | |
return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment