try this method
private boolean isHostRechable(String hostUrl) {
try {
URL url = new URL(hostUrl);
final HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
urlc.setRequestProperty("User-Agent", "Android Application");
urlc.setRequestProperty("Connection", "close");
urlc.setConnectTimeout(10 * 1000);
urlc.connect();
if (urlc.getResponseCode() == 200) {
return true;
}
} catch (Throwable e) {
e.printStackTrace();
}
return false;
}