以固定的时间间隔获取一个代号的位置 [英] Codename one retrieving location at regular time intervals

查看:75
本文介绍了以固定的时间间隔获取一个代号的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码使用代码名称一获取位置坐标 loc = LocationManager.getLocationManager().getCurrentLocation();

I am trying to get location coordinates using code name one using the following code loc = LocationManager.getLocationManager().getCurrentLocation();

我通过在 UITimer 中调用上述方法来定期运行上述方法.问题是我无法使用上述代码获得准确的位置.即使每10秒调用一次此方法,我也只能在4-5分钟的间隔内看到坐标的变化.我正在通过将设备携带在不断移动的车辆中进行测试.我已经尝试过使用 getCurrentLocationSync(),但是没有运气.对提高定位精度有何建议?

I am invoking the above method to run at regular intervals by calling it inside a UITimer. The problem is I am not able to get the accurate location using the above code. Even though this method is called for every 10 seconds I see change in coordinates only at 4-5 minutes interval. I am testing by carrying the device in vehicle which is moving constantly. I have tried using getCurrentLocationSync() but no luck. Any suggestions on improving the location accuracy?

推荐答案

您绝不能进行位置轮询,因为这会耗尽电池电量,并且无法在设备上正常工作.如果要在运行的应用程序上获取位置更新,只需将位置监听器与

You must never do location polling as it will kill the battery and doesn't work properly on devices. If you want to get location updates on a running application just use location listener with setLocationListener.

它会在您四处移动时被调用.

It will get invoked as you move around.

如果您希望在最小化应用程序时在后台获取位置事件,则需要

If you want to get location events in the background when your app is minimized then you will need the background location support (geofencing).

这篇关于以固定的时间间隔获取一个代号的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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