Android GPS 应用程序无法正确捕获位置
我是 Android 新手,刚刚开发了一个基于 GPS 的应用程序。它执行以下操作 -
- 在用户移动时使用叠加显示用户的路径
- 计算行进的总距离并计算总距离平均速度
为了获取用户的位置,如果已使用 -
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this); 注册了位置更新;
基本上,我尝试每 10 秒获取一次位置,然后相应地构建路径。
但是,在我的 HTC Legend 上进行测试时,我遇到了一些问题 -
- 当我开始记录轨迹时,GPS 接收器图标开始在顶部出现动画。有时,我没有收到任何通知的时间长达 在我开始接收更新后4-5 分钟
- ,有时 GPS 接收器图标保持静止,此时位置正常。但有时, 它再次开始闪烁,之后我没有得到任何位置,它仍然闪烁,我必须重新启动应用程序才能使其再次工作
我做错了什么? 10秒的频率是否太早了?我无法使用网络提供,因为我必须构建准确的路径,网络 提供商不提供准确的路径。 GPS接收器如何工作?什么时候会闪烁?什么时候停止?
请帮忙
谢谢!!
I am new to android and have just developed a GPS based application. It does the following -
- Displays the path of the user using Overlays while the user is moving
- Calcuates the total distance travelled & average speed
For obtaining the location of the user, if have registered the location updates using -
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 0, this);
Basically, I have tried getting the location every 10 seconds and then build the path accordingly
However, while testing this on my HTC Legend, I am facing few problems -
- When I start recording the track, the GPS receiver icon starts animating on the top. At times, I don't receive any lcoation for as long as
4-5 minutes - After I start receiving the updates, at times, the GPS receiver icon remains static, at that time location comes fine. But at times,
it again starts blinking and I don't get any location after that, it remains blinking and I have to restart the app to make it working again
What am I doing wrong? Is the 10 seconds frequency too early? I can't use a Network provide since I have to build a accurate path, Network
providers don't give accurate path. How does the GPS receiver work? When does it blink? When does it stops?
Please help
Thanks !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否在 locationListener 类中编写了“public void onLocationChanged(Location loc)”方法。它会在移动时为您提供更新的位置。
Have you written "public void onLocationChanged(Location loc)" method in your locationListener class. It will give you updated location while moving.
当 GPS 无法与足够的 GPS 卫星建立通信来找到您的位置时,GPS 图标会闪烁。
The gps icon blinks when it can't establish communication with enough gsp satellites to find your location.