Android后台服务无法解析/访问outlook.office365.com,除非手机负责?

Posted

技术标签:

【中文标题】Android后台服务无法解析/访问outlook.office365.com,除非手机负责?【英文标题】:Background service in Android cannot resolve/access outlook.office365.com, unless phone is in charge? 【发布时间】:2018-09-07 19:37:13 【问题描述】:

我一直在努力解决一个奇怪的问题。我有一个简单的代码,它通过 REST API 对 office365 进行身份验证并读取当天的日历条目。 当我的应用程序在前台运行时,代码运行良好。我得到所有日历事件,生成我的通知,一切都很好。 当我将应用程序置于后台时(该应用程序实际上是连接到 android AlarmManager - AlarmManager.RTC_WAKEUP 并重复运行的后台服务),通知停止出现。当我插入调试电缆查看 Logcat 时,突然之间,即使我的应用程序仍在后台,通知也开始出现。我一拔掉电缆,它们就停止了。当我查看未插入电话时的调试日志时,这就是我所看到的。我使用 Volley 进行网络连接,在此之前我使用的是 okhttp3。以下是两者的日志:

排球:

03-28 16:47:56.822 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:47:56.822 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:03.899 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:03.900 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:08.930 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:08.931 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:13.959 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:13.959 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:18.989 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:18.990 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:24.028 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:24.034 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:29.068 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:29.070 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:34.100 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:34.100 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:39.115 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
03-28 16:48:39.116 27031-27685/com.microsoft.samples.outlookquickstart I/System.out: (HTTPLog)-Static: isSBSettingEnabled false

okhttp3:

03-28 12:40:08.114 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err: java.net.SocketTimeoutException: connect timed out
03-28 12:40:08.115 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at java.net.PlainSocketImpl.socketConnect(Native Method)
03-28 12:40:08.115 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at     java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:33    4)
03-28 12:40:08.115 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at     java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.    java:196)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at     java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at java.net.Socket.connect(Socket.java:586)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.java:69)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)
03-28 12:40:08.116 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03-28 12:40:08.117 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at     okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at     okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err: at     okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:147)
03-28 12:40:08.118 10329-20079/com.microsoft.samples.outlookquickstart W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
03-28 12:40:08.119 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
03-28 12:40:08.120 10329-20079/com.microsoft.samples.outlookquickstart W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
03-28 12:40:08.120 10329-20079/com.microsoft.samples.outlookquickstart     W/System.err:     at java.lang.Thread.run(Thread.java:762)

我不确定是什么问题以及如何解决它。

关于问题是什么的任何想法?有人遇到过这个吗?我使用的是三星 Galaxy A5 2017。在其他品牌的手机上没有任何不同。

谢谢!

【问题讨论】:

【参考方案1】:

对于可能遇到相同问题的其他人:

经过一番挣扎,我找到了答案。 答案是节电程序已打开,而神秘消息意味着后台网络功能已被节电程序禁用。 一旦我关闭了省电模式,所有通知都开始定期发送,没有任何问题。为了进行测试,我将其关闭,通知因同样的错误而停止。

【讨论】:

以上是关于Android后台服务无法解析/访问outlook.office365.com,除非手机负责?的主要内容,如果未能解决你的问题,请参考以下文章

网关配置错误导致Outlook无法连线

outlook为啥总是验证身份失败?

无法在 Outlook Android 中设置收件人

无法停止后台服务android

Exchange2010 升级到 2016,2010用户无法通过2016代理访问邮箱,导致连接失败。

outlook邮箱服务器冲突导致无法自动更新接收文件怎么办