Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
isConnected Android. Check if device is connected
private static boolean isConnected(Context context) {
ConnectivityManager connectivityManager = (ConnectivityManager)
NetworkInfo networkInfo = null;
if (connectivityManager != null) {
networkInfo =
return networkInfo == null ? false : networkInfo.isConnected();
Copy link

ff-frida commented Feb 23, 2017

Hello, when connecting WiFi, networkInfo.isConnected () to return to false, you have encountered this problem, I am very strange.
Environment: Xiaomi Android 5.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment