I am creating an Android application that checks my internet connection. I want to display a toast message when my internet connection is very slow. Or when the server does not respond to the request. In this case, I want to put a toast as Connection is slow !. Here, in my code, I found whether the Internet is connected or not, but I don’t know how to toast messages about Internet slow ...
public boolean isConnectingToInternet(){
ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null)
{
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
for (int i = 0; i < info.length; i++)
if (info[i].getState() == NetworkInfo.State.CONNECTED)
{
return true;
}
}
return false;
}
source
share