问题描述
问题:
用户可以选择多长时间以及何时开始跟踪locaton(就像今天一样,从08:00至16:00)。所以,这个区间我的应用程序将侦听的位置每5分钟内(这段时间是可以改变的,这是一个用户的preference)。
The user can choose how long and when start to track your locaton (Like today from 08:00 to 16:00). So during this interval my application will listen for the location every 5 minutes (this time can be changed, it's a user's preference).
我在想什么:
拨打服务运行与听力用于由用户definned的时间间隔期间GPS或网络位置的到来。
Making a service to be running and listenning for coming of the GPS or network locations during the time interval definned by the user.
问题:
该服务可以运行很长一段时间被删除?
The service can be removed for running a long time?
我要注册听众GPS和网络(即使他们尚未启用)在启动服务时或我需要注册和删除监听器根据全球定位系统和网络的状态?
I need to registers listeners to GPS and Network (even if they have not enabled) when starting the service or I need to register and remove Listener depending status of GPS and Network?
我的服务将继续即使用户不使用手机很长一段时间(如一个小时)吧?
My service will continue running even if the user is not using the phone for a long time (like an hour) right?
推荐答案
您并不需要注册一个服务这一点。您可以使用麦墨菲库。
You don't need to register a Service for this. You can use Mak Murphy's cwac-locpoll library.
这是从上面的链接页面所采取的库的简短说明。您还可以找到code例子有:
This is a short description of the library taken from the page linked above. You'll also find code examples there.
您只需设置一个AlarmManager报警联系LocationPoller你希望的任何频率,它会处理所有的工作地点从那里,通过广播发送意向你的结果。然后,您的广播接收器可以使用位置数据作为必要的。
这篇关于跟踪用户位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!