Sunday, January 20, 2013

Check if internet is available:



//return true if the application can access the internet

private static boolean haveInternet(Context context) {
NetworkInfo info = ((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info == null || !info.isConnected())
{
return false;
}
if (info.isRoaming()) {
return true;
}
return true;
}

No comments:

Post a Comment