Created
August 24, 2014 17:20
-
-
Save j-onathan/a957ac5632c00e8671ef to your computer and use it in GitHub Desktop.
Android Code Example: Querying Network Reachability (from https://www.codota.com/android/scenarios/52fcbcf7da0a0798c77ab61b/querying-network-reachability?tag=dragonfly)
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
public static boolean haveNetworkConnection(Context context) { | |
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); | |
if(activeNetwork == null) return false; | |
return activeNetwork.isConnected(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment