How to Keep the CPU of android phone always awake?

二次信任 提交于 2019-12-02 02:42:24

First of all, your SimpleWakefulService does not look very wakefull, it should aqurie WakeLock but it doesnt. For example of such service look here:

https://github.com/commonsguy/cwac-wakeful/blob/master/wakeful/src/com/commonsware/cwac/wakeful/WakefulIntentService.java

Next thing, is update function. It is called in the context where PARTIAL_WAKE_LOCK is aquired, but the thread within it is executed asynchronously, that means also after wakelock is released. And that is whats causing problems.

Solution is to move your thread code from update function (thread is not needed) to WakefulIntentService as in above link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!