To detect whether internet is connected or not I am using the following code:
public boolean netConnect(Context ctx)
{
ConnectivityManager cm;
NetworkInfo info = null;
try
{
cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
info = cm.getActiveNetworkInfo();
}
catch (Exception e)
{
e.printStackTrace();
}
if (info != null)
{
return true;
}
else
{
return false;
}
}
Which is working perfectly fine .
But I want to know if the internet connection goes off at the time when app is downloading some files from server(I mean to say in between the process) is there anyway to detect that and display that internet connection lost or weak?