189 8069 5689

在程序代码中对wifi网络发生变化情况进行处理-创新互联

当wifi功能被关闭时,在Log中看到以下和wifi状态改变有关的日志:

网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、微信小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了呼图壁免费建站欢迎大家使用!
11-04 11:09:34.559: E/WifiService(185): Handle MESSAGE_DISABLE_WIFI.
11-04 11:09:34.569: D/DATA(287): [DCT(0) ] intent received :android.net.wifi.WIFI_STATE_CHANGED
11-04 11:09:34.569: D/StatusBarPolicy(254): updateWifi: android.net.wifi.WIFI_STATE_CHANGED : wifi state: 0 supplicant connected: false
11-04 11:09:34.579: I/wpa_supplicant(8310): CTRL-EVENT-TERMINATING - signal 15 received
11-04 11:09:34.579: V/WifiMonitor(185): Event [CTRL-EVENT-TERMINATING - signal 15 received]
11-04 11:09:34.579: V/WifiStateTracker(185): handleMessage(): msg.what= 2

在当前程序中没有对wifi断开进行处理,所以出现以下异常:

11-04 11:09:35.889: E/DownThread(7389): Connection timed out
11-04 11:09:35.889: E/DownThread(7389): java.net.SocketException: Connection timed out
11-04 11:09:35.889: E/DownThread(7389):     at org.apache.harmony.luni.platform.OSNetworkSystem.read(Native Method)
11-04 11:09:35.889: E/DownThread(7389):     at dalvik.system.BlockGuard$WrappedNetworkSystem.read(BlockGuard.java:273)
11-04 11:09:35.889: E/DownThread(7389):     at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:458)
11-04 11:09:35.889: E/DownThread(7389):     at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:85)
11-04 11:09:35.889: E/DownThread(7389):     at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
11-04 11:09:35.889: E/DownThread(7389):     at org.apache.harmony.luni.internal.net.www.protocol.http.FixedLengthInputStream.read(FixedLengthInputStream.java:44)
11-04 11:09:35.889: E/DownThread(7389):     at java.io.BufferedInputStream.read(BufferedInputStream.java:319)
11-04 11:09:35.889: E/DownThread(7389):     at java.io.FilterInputStream.read(FilterInputStream.java:133)
11-04 11:09:35.889: E/DownThread(7389):     at com.tvie.ivideo.download.logic.DownThread.run(DownThread.java:65)

出现异常的代码是InputStream的read方法。

while ((len = is.read(buffer)) != -1 && running) {

read方法的声明表现会抛出IOException。

int java.io.InputStream.read(byte[] buffer) throws IOException

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站题目:在程序代码中对wifi网络发生变化情况进行处理-创新互联
网站路径:http://jkwzsj.com/article/depceg.html

其他资讯