在同一时间多个位置提供

编程入门 行业动态 更新时间:2024-10-12 12:34:33
本文介绍了在同一时间多个位置提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一些问题与定位系统。我有一个实现LocationListener的服务。我想如果可能的话,使用GPS网络,以获得最佳的位置,如果网络是不够准确(精确度高于300吨以上)。问题是这样的。我需要的位置(精确如果可能的话,inaccuarte otherways)每5分钟。我开始一个:

I have some problems with location systems. I have a service that implements locationlistener. I want to get the best location using network when possible, gps if network is not enough accurate (accuracy greater than 300mt). The problem is this. I need location (accurate if possible, inaccuarte otherways) every 5 minutes. I start with a :

LocationManager lm=(LocationManager)getApplicationContext().getSystemService(LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_COARSE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); String provider=lm.getBestProvider(criteria, true); if(provider!=null){ lm.requestLocationUpdates( provider,5*60*1000,0,this);

在onLocationChanged我听的位置,当我得到的精度比大于300吨的位置,我想改变GPS定位系统。

In "onLocationChanged" i listen to locations and when i get a location with accuracy greater than 300mt, i want to change to gps location system.

如果我删除allupdates,然后GPS更新请求,就像这样:

If I remove allupdates and then request for gps updates, like this:

lm.removeUpdates((android.location.LocationListener) this); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); String provider=lm.getBestProvider(criteria, true); if(provider!=null){ lm.requestLocationUpdates( provider,5*60*1000,0,this); }

系统将停止等待gpsupdate,如果我在一个封闭的房间我就可以留而无需小时位置更新,忽略timeupdate迹象。有没有办法告诉locationprovider切换到网络,如果GPS是不是在给X秒的位置?或如何理解在GPS不可本地化?

system stops waiting for gpsupdate, and if i'm in a close room it can stay without location updates for hours, ignoring timeupdate indications. Is there a way to tell locationprovider to switch to network if gps is not giving a location in "x" seconds? or how to understand when gps is not localizing?

或者如果我从(网络和GPS)2提供商在同一时间requestlocationupdates,可以是一个问题吗?

or if i requestlocationupdates from 2 providers at same time (network and gps), can be a problem?

任何建议?

推荐答案

我在写具体到你的问题的答案,但后来我意识到没有办法我可以雁与此的优秀资源的Andr​​oid开发人员指南提供。它解释了怎么样了,在个为什么,优点和位置听众的缺点。

I was writing an answer specific to your question, but then I realized there was no way my anser could compete with this excellent resource the Android dev guide provides. It explains the hows, the whys, the pros and the cons of location listeners.

如果你要倒在Android上的GPS道路,这是一个必须阅读。它回答你上面的问题等等。相信我,这是值得你的时间。

If you're going down the GPS road in Android, it's a must-read. It answers your above question and many more. Trust me, it's worth your time.

有也设置有实现有用的例子每个SDK中的样品。我是pretty肯定是一个位置的例子。

There's also the samples provided with each SDK that implement useful examples. I'm pretty sure the was a location example.

更多推荐

在同一时间多个位置提供

本文发布于:2023-11-24 00:26:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623310.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   位置   时间   在同一

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!