從舊的帖子如Android java.net.UnknownHostException: Host is unresolved (strategy question),它建議使用下面的代碼:Android DNS需要預熱嗎?
try {
InetAddress i = InetAddress.getByName(URLName);
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
所以它的意思是當一個DNS條目沒有在設備中,例如緩存啓動後,它會第一次返回java.net.UnknownHostException: Host
,即使是有效的DNS?