简体   繁体   English

跟踪用户位置

[英]Tracking user location

Problem: 问题:

The user can choose how long and when start to track your locaton (Like today from 08:00 to 16:00). 用户可以选择跟踪位置的时间和开始时间(今天从08:00到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). 因此,在此间隔内,我的应用程序将每5分钟监听一次位置(此时间可以更改,这是用户的偏好)。

What I'm thinking: 我在想什么:

Making a service to be running and listenning for coming of the GPS or network locations during the time interval definned by the user. 使服务运行并在用户定义的时间间隔内侦听GPS或网络位置的到来。

Problem: 问题:

The service can be removed for running a long time? 该服务可以删除长时间运行吗?

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? 启动服务时,我需要注册GPS和网络侦听器(即使尚未启用),还是需要根据GPS和网络的状态注册并删除侦听器?

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. 您可以使用Mak Murphy的cwac-locpoll库。

This is a short description of the library taken from the page linked above. 这是对库的简短描述,摘自上面链接的页面。 You'll also find code examples there. 您还将在此处找到代码示例。

You simply set up an AlarmManager alarm to contact LocationPoller on whatever frequency you wish, and it will handle all of the location work from there, sending you the results via a broadcast Intent. 您只需设置一个AlarmManager警报即可以所需的任何频率与LocationPoller联系,它将从那里处理所有定位工作,并通过广播Intent将结果发送给您。 Your BroadcastReceiver can then use the location data as needed. 然后,您的BroadcastReceiver可以根据需要使用位置数据。

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

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