我有一个应用程序,用户单击按钮即可执行备份(脱机)和还原(脱机).但是,我不知道哪种后台服务适合使用.在这种情况下,有人可以建议我使用 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:要使用哪个后台服务?
发布评论