检测使用GPS固定设备 [英] Detect stationary device using GPS

查看:91
本文介绍了检测使用GPS固定设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建提醒用户的应用程序,如果他一直固定数分钟(如10)。

I am creating an app that alerts user if he has been stationary for a few minutes(say 10).

我发现很容易检测运动,用LocationListener的,如果设备移动一定的距离触发功能。

I find it easy to detect motion, using LocationListener which triggers a function if device moved a certain distance.

不过,我想不同的东西。我想,如果设备没有为特定的时间持续移动一个函数被调用

However, I want something different. I want a function to be called if the device did not move for a certain duration of time.

我如何做到这一点?

推荐答案

您可以轻松地设置一个计时器,当LocationListener的火灾,计时器归零。如果计时器达到10分钟,那么你知道,用户没有移动。这样做的缺点的方法是,定时器必须继续运行,所以你需要安装为服务。

You could easily set a timer and when the LocationListener fires, reset the timer to zero. If the timer reaches 10 minutes, then you know that the user hasn't moved. The downside to this approach is that the timer must continue to run, so you will need to install as a service.

http://developer.android.com/reference/java/util/ Timer.html

这篇关于检测使用GPS固定设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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