Android:要使用哪个后台服务? [英] Android: Which Background Service to use?
问题描述
我有一个应用程序,用户单击按钮即可执行备份(脱机)和还原(脱机).但是,我不知道哪种后台服务适合使用.在这种情况下,有人可以建议我使用 WorkerManager 还是服务吗?
I have an app where a user can perform a backup (offline) and restore (offline) on a button click. However, i don't know which background service is appropriate to use. Can someone advise me whether to use WorkerManager or Service in this case?
推荐答案
我建议您使用ForegroundService
,因为使用这些服务的目的是长期运行的进程,应该通知用户并与之交互.
I recommend you to use ForegroundService
as of the goal of using these services are Long Running Processes that Users should be informed and interact with it .
考虑使用ForegroundService
尝试备份时,可以向用户显示
Consider when you try to backup when you Use ForegroundService
then you can show to user
- 从头到尾的过程
- 取消备份
- 暂停
- 等等
所以我建议您使用这种方法.
So I recommend you to use this approach .
这篇关于Android:要使用哪个后台服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!