How to check host connection with internet connection
I want to full check connection to internet and a domain or host. I used a
method to check internet connection, but i can not add checking host
availability. My code is here;
public class InternetCheck{
public static boolean isInternetAvailable(Context context)
{
NetworkInfo info = (NetworkInfo) ((ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info == null){
Constants.connectionProblem = "Check your internet connection";
return false;
}
else{
return true;
}
}
}
I want to add host or domain availability check inside of
isInternetAvailable() method. It must return false and set
Constant.connectionProblem = "Host is not available" . Because, i will
call that method on my main activity and if it returns false, i will show
a Toast which shows that Constants.connectionProblem .
No comments:
Post a Comment