我有一个可以下载非常大的文件(超过50MB)的应用程序。不幸的是,我收到下载失败的报告。
下面是一个这样的失败的logcat,以java.net.SocketException: The operation timed out
结束。在它之间它有来自WifiMonitor
的各种消息。我不知道如何解释这些消息。
我是否应该采取一些特殊措施来下载大文件,或者这只是一个连接问题?
09-02 16:41:19.925 I/ActivityManager( 646): Displayed activity com.example/com.example.sp.MainActivity: 1110 ms (total 3786 ms)
09-02 16:41:21.935 W/InputManagerService( 646): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@45133d08
09-02 16:41:23.495 I/global ( 7345): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
09-02 16:41:23.895 D/dalvikvm( 7345): GC freed 5348 objects / 307096 bytes in 160ms
09-02 16:41:25.885 D/dalvikvm( 7345): GC freed 15282 objects / 713544 bytes in 124ms
09-02 16:41:27.405 D/dalvikvm( 7345): GC freed 11775 objects / 524576 bytes in 131ms
09-02 16:41:28.982 I/wpa_supplicant( 7284): CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
09-02 16:41:28.985 V/WifiMonitor( 646): Event [CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys]
09-02 16:41:28.985 V/WifiStateTracker( 646): New network state is DISCONNECTED
09-02 16:41:28.985 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=0
09-02 16:41:28.985 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=0]
09-02 16:41:28.995 V/WifiStateTracker( 646): Changing supplicant state: COMPLETED ==> DISCONNECTED
09-02 16:41:29.086 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=2
09-02 16:41:29.086 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=2]
09-02 16:41:29.086 V/WifiStateTracker( 646): Changing supplicant state: DISCONNECTED ==> SCANNING
09-02 16:41:29.086 W/wpa_supplicant( 7284): Failed to initiate AP scan.
09-02 16:41:29.095 I/wpa_supplicant( 7284): CTRL-EVENT-SCAN-RESULTS Ready
09-02 16:41:29.095 I/wpa_supplicant( 7284): Trying to associate with 00:1c:f0:6e:2a:56 (SSID='WLANR' freq=2412 MHz)
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 E/wpa_supplicant( 7284): Set_key: Wrong Key
09-02 16:41:29.095 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=3
09-02 16:41:29.105 V/WifiMonitor( 646): Event [Trying to associate with 00:1c:f0:6e:2a:56 (SSID='WLANR' freq=2412 MHz)]
09-02 16:41:29.105 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=3]
09-02 16:41:29.125 V/WifiStateTracker( 646): Changing supplicant state: SCANNING ==> ASSOCIATING
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=4
09-02 16:41:29.825 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=4]
09-02 16:41:29.825 V/WifiStateTracker( 646): Changing supplicant state: ASSOCIATING ==> ASSOCIATED
09-02 16:41:29.825 I/wpa_supplicant( 7284): Associated with 00:1c:f0:6e:2a:56
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-STATE-CHANGE id=0 state=7
09-02 16:41:29.825 I/wpa_supplicant( 7284): CTRL-EVENT-CONNECTED - Connection to 00:1c:f0:6e:2a:56 completed (reauth) [id=0 id_str=]
09-02 16:41:29.825 I/wpa_supplicant( 7284): wpa_supplicant - IPC_EVENT_AUTH_SUCC
09-02 16:41:29.825 V/WifiMonitor( 646): Event [Associated with 00:1c:f0:6e:2a:56]
09-02 16:41:29.825 V/WifiMonitor( 646): Event [CTRL-EVENT-STATE-CHANGE id=0 state=7]
09-02 16:41:29.845 V/WifiStateTracker( 646): Changing supplicant state: ASSOCIATED ==> COMPLETED
09-02 16:41:29.855 V/WifiMonitor( 646): Event [CTRL-EVENT-CONNECTED - Connection to 00:1c:f0:6e:2a:56 completed (reauth) [id=0 id_str=]]
09-02 16:41:29.855 V/WifiStateTracker( 646): New network state is CONNECTED
09-02 16:41:29.865 D/WifiStateTracker( 646): Deconfiguring interface and stopping DHCP
09-02 16:41:29.865 E/wpa_supplicant( 7284): prepare_filter_struct: type=5
09-02 16:41:29.945 E/FileUtils( 7345): Download failed
09-02 16:41:29.945 E/FileUtils( 7345): java.net.SocketException: The operation timed out
答案 0 :(得分:4)
手机在进入睡眠模式时与Wi-Fi断开连接,我猜这是原因吗?看看WifiManager's WifiLock to see how you can prevent it.