AlarmManager 是否使 Wifi 保持唤醒状态,或者是否需要wakeLock?

发布于 2024-12-16 14:31:36 字数 141 浏览 7 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪之触 2024-12-23 14:31:36

是的,您需要 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文