Does service.startForeground imply wakelock?

只愿长相守 提交于 2019-12-05 21:13:20

To answer my own question (if no one else finds more details on this):

In my understanding "foreground" just describes that the user would notice if the app was killed e.g. when browsing a large page. For this reason the system is asked to try to avoid killing the service.

  • Just because a foreground service is running probably not implies that the CPU can't go into deep sleep mode.

In order to collect sensor data all the time from user-defined start to stop we still need to aquire the WakeLock ourselves.

No, wakelock can be used to make sure your foreground services run when device goes to sleep

If you must use partial wake locks, follow these recommendations:

  • Make sure some portion of your app remains in the foreground. For example, if you need to run a service, start a foreground service instead. This visually indicates to the user that your app is still running.

https://developer.android.com/topic/performance/vitals/wakelock#best_practices

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