即时通讯开发一个原生的Android应用程序,没有错误,但logcat的说如何处理java.net.ConnectException有效
Caused by: java.net.ConnectException: failed to connect to some ip.
Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT
由Android指出警戒线 - 工作室 -
HttpResponse httpResponse = httpClient.execute(httpPost);
当您的应用程序无法与LAN上的本地服务器通信时,会发生此问题。
任何人都可以建议我有条件处理这个Exceptions efferntly? 只想我的应用程序没有错误和警告。
可能我们可以使用一个try - catch
?至少,只是为了显示吐司“连接错误”:)
这里提到http://hpp.com/files/32954067/java-net-connectexception-failed-to-connect-to-10-0-0-2-port-80-connect-fai和from这也太http://stackoverflow.com/questions/20028648/client-socket-times-out-when-connecting-to-server –
其实我早就做了一些研究,gottcha! – Vikrant