A_r*_*mas 4 webserver android exception
我的应用程序需要检查我成功实现的互联网访问。但是我有一个条件,可以使用互联网,但是它正在尝试打开的网站目前已关闭。在这种情况下,我需要显示不同的消息作为输出。我该怎么办?请给点想法。
public boolean isServerReachable()
// To check if server is reachable
{
try {
InetAddress.getByName("google.com").isReachable(3000); //Replace with your name
return true;
} catch (Exception e) {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)