使用全球定位系统和网络提供商,同时在Android中 [英] Use GPS and Network Provider at the same time in Android

查看:122
本文介绍了使用全球定位系统和网络提供商,同时在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了我的应用程序一个LocationListener的,它使用的网络提供商。

I have implemented a locationlistener in my app which uses the Network Provider.

这一切工作正常,因为我很快要的位置,并与GPS提供它需要年龄。

This all works fine because i want a location quickly and with GPS Provider it takes ages.

不过,我来我的应用程序一个点的位置必须准确(最大5-10meters)。

But I've come to a point in my app where location has to be accurate (max 5-10meters).

我想知道是否有可能使用与网络供应商的GPS供应商在同一时间,然后同时获得的最好成绩? 而且是它也可以让我知道什么时候该GPS供应商给我提供了一个GPS定位?

I was wondering if it's possible to use the GPS provider with the Network Provider at the same time and then get the best result of both? And is it also possible to let me know when the GPS provider provided me with an GPS Location?

所以基本上:

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);

将这项工作与同重写onLocationChanged()?

Will this work with the same overridden onLocationChanged() ?

和我怎么能看到如果GPS已经得到了位置?

And how can I see if the GPS has gotten a Location?

谢谢

推荐答案

您当然可以使用相同的监听多个供应商。这可能是更好地准确使用locationmanager.getProviders与Criteria对象,然后排序或只是听他们。没有太大的实际差异,但。

You can certainly use the same listener for multiple providers. It may be better to use locationmanager.getProviders with a Criteria object then sort by accuracy or just listen to all of them. Not much practical difference though.

在onLocationChanged回调给你一个位置的对象,其中有一个getProvider()方法,你可以用它来确定它来自何处。它也有一个getAccuracy()方法,所以你也可以你的最新的修补程序通过精确排序。

The onLocationChanged callback gives you a Location object, which has a getProvider() method you can use to determine where it came from. It also has a getAccuracy() method, so you could also sort your recent fixes by accuracy.

这篇关于使用全球定位系统和网络提供商,同时在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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