简体   繁体   English

用于地理位置跟踪的前台或后台服务

[英]Foreground or background service for geo location tracking

In order to create a location tracking system (based on fusedlocationprovider) which has to track the location of a person for a specific period of time.为了创建一个位置跟踪系统(基于 fusedlocationprovider),它必须在特定时间段内跟踪一个人的位置。

At specific intervals, the location needs to be broadcast and the service should not be killed even if the application is closed.在特定的时间间隔,需要广播位置,即使应用程序关闭,也不应该杀死服务。

Should I be using a foreground or background service or a combination of both and an explanation would help a lot.我应该使用前台服务还是后台服务,还是两者结合使用,并且解释会有很大帮助。

if you want to get location for specific interval of time you can use work manager for that but, you want to use service only which you need not to be killed then you should use foreground service according to googles guide line if the service without foreground notification it will be stop when app get killed.如果您想获取特定时间间隔的位置,您可以使用工作管理器,但是,您只想使用不需要被杀死的服务,那么如果服务没有前台通知,您应该根据谷歌指南使用前台服务当应用程序被杀死时它将停止。

https://developer.android.com/guide/background/ https://developer.android.com/guide/background/

https://codelabs.developers.google.com/codelabs/android-workmanager/#11 https://codelabs.developers.google.com/codelabs/android-workmanager/#11

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

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