Created
March 15, 2018 22:36
-
-
Save valterh4ck3r/6814c352863aead6bb51ec02c1fb47ee to your computer and use it in GitHub Desktop.
Detect Network Android
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 static boolean isOnline(Context context) { | |
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo networkInfo =connectivityManager.getActiveNetworkInfo(); | |
return networkInfo != null && networkInfo.isConnected(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment