简体   繁体   English

跟踪用户位置的前台或后台服务?

[英]Foreground or Background service to track user's location?

I'm developing a location aware app.我正在开发一个位置感知应用程序。 This app will start tracking users when they are in their workday.此应用程序将在用户工作日时开始跟踪用户。 These are the requirements:这些是要求:

  1. The service should run on a regular basis (every 30 or 45 min).该服务应定期运行(每 30 或 45 分钟)。
  2. It won't matter if the service does not trigger at the same basis everytime.如果服务不是每次都在相同的基础上触发,这并不重要。
  3. The service needs to upload data to our firestore db.该服务需要将数据上传到我们的 Firestore 数据库。
  4. I doesn't need to be triggered on specific conditions (data is on, phone is charging, etc...)我不需要在特定条件下触发(数据开启,手机正在充电等......)
  5. I need this to run even if the user restarts his phone.即使用户重新启动手机,我也需要运行它。
  6. We may need to track the distance traveled by the user.我们可能需要跟踪用户行进的距离。 (This is not a requirement per se, but it may be a feature someday) (这本身不是一个要求,但它可能有一天会成为一个功能)

I know there are a lot of ways to achieve this, but I have not decided which is the option that best fits my scenario.我知道有很多方法可以实现这一点,但我还没有决定哪个选项最适合我的场景。 This is what I've thought so far:这是我到目前为止的想法:

  • Foreground service combined with BroadcastReciever in case the phone is rebooted前台服务与 BroadcastReciever 相结合,以防手机重启
  • Background service using the new jetpack's Workmanager .使用新喷气背包的Workmanager的后台服务。

Which will the best solution?哪个会是最好的解决方案? Do you think there is a better solution than those?你认为有比这些更好的解决方案吗?

Thanks!谢谢!

Was thinking create a GPS location tracker so when they are in work premise as well as outside it kinda shows.正在考虑创建一个 GPS 位置跟踪器,这样当他们在工作场所以及在外面时它有点显示。 Then consider adding the number 5 of the above.然后考虑添加上面的数字5。 Like you said there could be mire awesome solutions than these so lets wait for options.就像你说的那样,可能有比这些更棒的解决方案,所以让我们等待选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM