我正在努力研究GcmNetworkManager工具中OneoffTask的setTag和setUpdateCurrent的行为。ThedocumentationofsetUpdateCurrent是这样说的:Optionalsettertospecifywhetherthistaskshouldoverrideanypreexistingtaskswiththesametag.Thisdefaultstofalse,whichmeansthatanewtaskwillnotoverrideanexistingone.很公平,但它没有说明任务会发生什么,它只说明了一件不会发生的事情——
我开始实现GcmNetworkManager以在用户恢复互联网连接时触发同步在查看OneoffTask的文档时,它说setExecutionWindow是强制性的Mandatorysetterforcreatingaone-offtask但是我只希望它在用户有互联网时执行,听起来它可以在用户有互联网之前执行,但在windowStartDelaySeconds和windowEndDelaySeconds的窗口中执行。那么这是否意味着网络管理器可以在windowEndDelaySeconds之前的某个时间执行任务,或者这是否意味着一旦internet恢复它就会在那个时间执行?
我正在尝试使用GCM网络管理器将日志发送到后端服务。我们有一个大约每小时运行一次的警报,它创建一个OneoffTask,在执行时,将使用日志消息调用后端服务。这行得通,但是大量的任务丢失了(超过一半)。起初,我认为这与我们的后端或网络有关,但在添加了大量文件日志记录后,事实证明这些任务永远不会触发服务中的onRunTask(但它们肯定会被安排。为什么?这些丢失了吗?是我误解了API,还是OneoffTasks根本不可靠?OneoffTask是这样安排的:GcmNetworkManager.getInstance(context).schedule(newOneoffTask.Build
我正在使用GcmNetworkManager来安排一个OneoffTask,其执行窗口从0开始。在documentations中它提到Notethatyoucanrequestaone-offtasktobeexecutedatanypointinthefuture,buttopreventabusetheschedulerwillonlysetanalarmataminimumof30secondsinthefuture.Yourtaskcanstillberunearlierthanthisifsomenetworkeventoccurstowakeupthescheduler.这