Created
February 26, 2013 14:06
-
-
Save philipesteiff/5038627 to your computer and use it in GitHub Desktop.
[Android] Verifica se existe conexão disponível, retornando TRUE caso haja. Obs: Funciona em smartphone e tablet.
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 isNetworkConnected(Context context){ | |
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo network = cm.getActiveNetworkInfo(); | |
if(network != null){ | |
return network.isAvailable(); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment