Created
June 30, 2016 07:03
-
-
Save talhahasanzia/c205bd7a477ca245d0797f33ace050d5 to your computer and use it in GitHub Desktop.
Check internet connection. This will check internet connection status, not actual connection response from a server.
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) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); | |
return activeNetworkInfo != null && activeNetworkInfo.isConnected(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will check internet connection status, not actual connection response from a server. To check actual response from internet, create asyncTask and try to connect to a website.
Needs permission: ACCESS_NETWORK_STATE