如何通知服务器上的用户的位置,每5分钟? [英] how to notify the server every 5 minutes on user's location?

查看:237
本文介绍了如何通知服务器上的用户的位置,每5分钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Android应用程序。

I write an android app.

我想向服务器发送用户的位置,每5分钟,即使他并没有移动。

I want to send the server the user's location every 5 minutes even if he hasn't moved.

如何建议我做吗?

使用定时器和刚刚发送的位置每5分钟

Using a Timer and just sending the location every 5 min

或使用与minDistance才会= 0米和minTime = 5分钟LocationListener的?

or using locationListener with minDistance = 0 m and minTime = 5 min?

推荐答案

AlarmManager ,将唤醒每5分钟,并使用 LocationListener的来获得当前位置发送给服务器。发送位置更新后,就注销(删除更新)LocationListener的。通过这种方式,您将提高电池性能。想象一下,在您的 LocationListener的保持在后台运行的情况。

Write a AlarmManager that would wake up every 5 minutes and use LocationListenerto get the current location to send to server. After sending location updates, just unregister(remove updates) the locationListener. In this way, you will be improving the battery performance. Imagine the case where your locationListener keeps running in the background.

这篇关于如何通知服务器上的用户的位置,每5分钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆