保持清醒的服务,而无需耗尽电池 [英] Keeping services awake without draining battery

查看:307
本文介绍了保持清醒的服务,而无需耗尽电池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有需求通过WiFi传入请求以连续欣赏的应用程序。在后台运行的服务来完成这个工作。然而,这种服务不久就睡着了屏幕关闭时。

I have an application that needs to continuously listen for incoming requests over wifi. A service that runs in the background does this job. However, this service falls asleep after a while when the screen turns off.

从我搜索到的解决方案是使用AlarmManager以保持清醒。但据说,这将排水设备的电池。
那么,有没有另一种方式来做到这一点?

The solution from what I have searched is to use AlarmManager to keep it awake. But it is said that this will drain the battery of the device. So, is there another way to do this?

有关例如,什么样的WhatsApp和Skype应用程序吗?他们似乎并没有杀死太多的电池,但他们已经连续运行的服务的权利?

For eg, what do apps like Whatsapp and Skype do? They don't seem to kill too much battery but they have continuously running services right?

此外,如果AlarmManager是唯一的出路,这将是非常亲切,如果有人可以分享的教程或例子吧。

Also, in case AlarmManager is the only way, it would be really kind if someone could share a tutorial or example for it.

推荐答案

其实它不是你的服务落在睡觉,它的Wi-Fi设备在设备上。制造商如HTC(或者所有的Andr​​oid设备)已经实施了这种在他们的设备的行为,其中无线单元关屏的特定时间段后,后进入待机状态。这有助于其设备不使用时,以节省电池。

Actually its not your service which falls to sleep, its your WiFi unit on the device. Manufacturers like HTC (or perhaps all Android devices) have implemented this kind of behavior on their devices in which the WiFi unit goes standby after certain time period of screen-off. This helps the devices to save battery when its not being used.

这篇关于保持清醒的服务,而无需耗尽电池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆