Last active
December 24, 2015 06:29
-
-
Save pietrorampini/6757044 to your computer and use it in GitHub Desktop.
isConnectedToNewtork
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 isConnectedToNewtork(Context context){ | |
boolean connected = false; | |
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
if (cm != null){ | |
NetworkInfo ni = cm.getActiveNetworkInfo(); | |
if (ni != null){ | |
connected = ni.isConnected(); | |
} | |
} | |
return connected; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment