Android:要使用哪个后台服务?

编程入门 行业动态 更新时间:2024-10-25 09:38:12
本文介绍了Android:要使用哪个后台服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

本文发布于:2023-11-27 09:31:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:要使   后台   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!