减少前台服务的电池消耗

时间:2019-05-03 14:30:24

标签: android android-service

我的应用程序通过调用startForeground()来启动将服务设置为前台的服务,因为该服务以前经常被取消。自从我添加startForeground()以来,该应用程序的电池消耗很高。

while (!stop){
    if ((System.currentTimeMillis()-prevMillis) >= intervalSerivce) {
       //get some HTML code and extract a value, if condition fulfilled call a funtion
    }

}

时间间隔仅为 30分钟 60分钟,具体取决于在if条件内代码获得的值。我认为这不是那么耗能。

我应该使用sleep()而不是currentTimeMillis()吗? 我还要考虑什么?

0 个答案:

没有答案
相关问题