/**
*
* This function is used to check whether Internet is (available)working or not
*
* @param context
*/
public static boolean isOnline(Context context)
{
try
{
ConnectivityManager conMgr = null;
conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (conMgr.getActiveNetworkInfo() != null && conMgr.getActiveNetworkInfo().isAvailable()
&& conMgr.getActiveNetworkInfo().isConnected())
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.