How to create background services for android Oreo without notifications like social networking applications Facebook, Messenger, Zalo

后端 未结 4 914
轻奢々
轻奢々 2021-01-28 16:05

I see some applications like Messenger, Zalo do not need notifications but still work in the background. How to do it. The devices I use are Xiaomi A1 (Android 8) and Nokia 6.1

4条回答
  •  不要未来只要你来
    2021-01-28 16:31

    No. For API levels of Oreo (i.e.: 26) or higher, you cannot start a service to work in the background when the app is not in the foreground without showing the foreground notification. One alternative is to use WorkManager, a convenient lib for background tasks that doesn't require a foreground notification. Check it out here: WorkManager

    The caveat with WorkManager though is that it does not allow you to execute tasks more frequently than once every 15 minutes. So if you need some background task to run every 30 seconds, 5 minutes, etc., you'll need to explore other options instead.

提交回复
热议问题