在同一时间多个位置提供 [英] More than one location provider at same time

查看:168
本文介绍了在同一时间多个位置提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题与定位系统。
我有一个实现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.

这篇关于在同一时间多个位置提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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