AlarmManager 是否使 Wifi 保持唤醒状态,或者是否需要wakeLock?
我使用 AlarmManger 为远程服务器安排一个保持活动计时器,因此每个间隔都会将 UDP 包发送到服务器。当发送的包或在 AlarmManager 上下文上运行的包足够时,我是否应该获得 Wifi/CPU 锁定? 注意:我正在运行一项服务以使应用程序保持在后台。
I'm using the AlarmManger to schedule a keep alive timer to remote server, so every INTERVAL an UDP package are send to the server. Should I get a Wifi/CPU lock when the package sent or running on the AlarmManager context is enough?
Note: I'm running a service to keep the application in background.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您需要 Wifi/CPU 锁才能执行此操作。但请注意,这样做会耗尽用户的电池。您应该找到一种与服务器异步通信的方法,例如使用 REST。 Android 让人们很容易找出哪些应用程序消耗了最多的电池电量,所以除非你想要大量卸载,否则你应该找到解决这个问题的方法。
Yes, you'll need a Wifi/CPU lock in order to be able to do this. A word of caution though, you're going to kill the users battery by doing this. You should figure out a way to communicate with your server asynchronously, like with REST. Android makes it really easy for people to figure out which apps are using up the most battery power, so unless you want a bunch of uninstalls, you should probably figure out a way around this.