Can I still have a data logging background service in Android 8.0?

ぐ巨炮叔叔 提交于 2019-11-28 14:31:13

If your usecase is to keep the app in foreground during this processing then, based on the documentation, there shouldn't be any problem, since the restrictions for background service is applied if your app is not in Foreground or no foreground app is connected to the app

X minutes (based on my observations its around 1 - 2 minutes) after your app enters in background all the restrictions for background service will kick in and your Service will be stopped as if you have called Service.stopSelf()

You should avoid doing it continuously, since it will impact battery life of the device, if are intending to do in background. You can perform logging periodically using JobScheduler/AlarmManager.

If you still want to proceed, you can make the service ForegroudService and perform the operation but if system considers your task as CPU intensive then this approach wont' work either

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