在android应用程序中,我每隔X分钟就从服务(foregrounded)轮询服务器(这是必要的)。每当应用程序在前台运行时我得到正确的响应,但是当应用程序在后台运行时,在一些成功的响应之后,我每次都会收到“连接被拒绝”错误。
我不明白为什么它不在后台工作。
WifiService( 972): releaseWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@9a93161}
V/LocationPolicy( 972): onProcessStateChanged
D/LBSSystemMonitorService( 972): handleMessage what - 3
D/Wiper_jni( 972): Send Network Location.
V/NotificationService( 972): enqueueNotificationInternal: pkg=com.testserver id=27 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x2 color=0x00000000 actions=1 vis=PRIVATE)
I/JSONDATAPOSTMETHOd( 2347): /**/JSON POST method to be called...
I/JSONPOSTBEGIN( 2347): Beginning of JSON POST
D/NotificationService( 972): [csl] buzzBeepBlinkLocked() zenMode = 3, zenConfig = ZenModeConfig[allowCalls=true,allowMessages=false,allowFrom=contacts,allowEvents=false,allowMusic=false,allowAlarm=true,allowVibrate=true,allowLight=true,sleepMode=null,sleepStart=22.0,sleepEnd=7.0,conditionComponents=null,conditionIds=null,exitCondition=null,exitConditionComponent=null]
V/NotificationService( 972): pkg=com.testserver canInterrupt=true intercept=false
D/LBSSystemMonitorService( 972): handleMessage what - 7
V/NotificationService( 972): Interrupting!
D/Wiper_jni( 972): Send Passive Location.
D/PhoneStatusBar( 1286): updateNotification pkg=com.testserver;id=27
D/FastDormancyService( 4139): detect mobile data activity! isAlarmExpired: false mFDset: 3
D/FastDormancyService( 4139): sent:1 received:0
D/FastDormancyService( 4139): scheduling timer:1000ms Alarm:10000ms
I/XiaomiFirewall( 1385): firewall pkgName:com.testserver, result:0x0
D/IconCustomizer( 1478): Content Ratio = 1.1294118
V/NotificationService( 972): enqueueNotificationInternal: pkg=com.miui.securitycenter id=1000 notification=Notification(pri=2 contentView=com.miui.securitycenter/0x7f030009 vibrate=null sound=null defaults=0x0 flags=0x2 color=0x00000000 vis=PRIVATE)
D/NotificationService( 972): [csl] buzzBeepBlinkLocked() zenMode = 3, zenConfig = ZenModeConfig[allowCalls=true,allowMessages=false,allowFrom=contacts,allowEvents=false,allowMusic=false,allowAlarm=true,allowVibrate=true,allowLight=true,sleepMode=null,sleepStart=22.0,sleepEnd=7.0,conditionComponents=null,conditionIds=null,exitCondition=null,exitConditionComponent=null]
V/NotificationService( 972): pkg=com.miui.securitycenter canInterrupt=true intercept=false
V/NotificationService( 972): Interrupting!
I/MSM-irqbalance( 435): Decided to move IRQ65 from CPU4 to CPU7
D/PhoneStatusBar( 1286): updateNotification pkg=com.miui.securitycenter;id=1000
D/FastDormancyService( 4139): detect mobile data activity! isAlarmExpired: false mFDset: 3
D/FastDormancyService( 4139): sent:0 received:1
D/FastDormancyService( 4139): scheduling timer:1000ms Alarm:10000ms
D/InputStream( 2347): Error org.apache.http.conn.HttpHostConnectException: Connection to http://www.testserver.com refused
I/JSONPOSTEND( 2347): End of JSON data post methos...
V/NotificationService( 972): enqueueNotificationInternal: pkg=com.testserver id=27 notification=Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x2 color=0x00000000 actions=1 vis=PRIVATE)
/WifiService( 972): acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@9a93161}