<bdo id='iAvb1'></bdo><ul id='iAvb1'></ul>

    <small id='iAvb1'></small><noframes id='iAvb1'>

        <tfoot id='iAvb1'></tfoot>
        <legend id='iAvb1'><style id='iAvb1'><dir id='iAvb1'><q id='iAvb1'></q></dir></style></legend>
        <i id='iAvb1'><tr id='iAvb1'><dt id='iAvb1'><q id='iAvb1'><span id='iAvb1'><b id='iAvb1'><form id='iAvb1'><ins id='iAvb1'></ins><ul id='iAvb1'></ul><sub id='iAvb1'></sub></form><legend id='iAvb1'></legend><bdo id='iAvb1'><pre id='iAvb1'><center id='iAvb1'></center></pre></bdo></b><th id='iAvb1'></th></span></q></dt></tr></i><div id='iAvb1'><tfoot id='iAvb1'></tfoot><dl id='iAvb1'><fieldset id='iAvb1'></fieldset></dl></div>
      1. 在网络和 GPS 提供商之间切换

        时间:2023-09-02

            <bdo id='vmemk'></bdo><ul id='vmemk'></ul>
                <i id='vmemk'><tr id='vmemk'><dt id='vmemk'><q id='vmemk'><span id='vmemk'><b id='vmemk'><form id='vmemk'><ins id='vmemk'></ins><ul id='vmemk'></ul><sub id='vmemk'></sub></form><legend id='vmemk'></legend><bdo id='vmemk'><pre id='vmemk'><center id='vmemk'></center></pre></bdo></b><th id='vmemk'></th></span></q></dt></tr></i><div id='vmemk'><tfoot id='vmemk'></tfoot><dl id='vmemk'><fieldset id='vmemk'></fieldset></dl></div>

                    <tbody id='vmemk'></tbody>

                  <legend id='vmemk'><style id='vmemk'><dir id='vmemk'><q id='vmemk'></q></dir></style></legend>
                1. <tfoot id='vmemk'></tfoot>
                2. <small id='vmemk'></small><noframes id='vmemk'>

                3. 本文介绍了在网络和 GPS 提供商之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想实现一个 locationListener,它将根据可用性在网络和 GPS 提供商之间切换.

                  I want to implement a locationListener which will switch between network and GPS providers based on availability.

                  例如,如果 GPS 未启用,我希望它使用网络,但一旦 GPS 开启,我希望它停止侦听来自网络的位置更新并开始侦听 GPS.

                  For example if GPS is not enabled I want it to use network but as soon as GPS is on then I want it to stop listening for location updates from network and start listening from GPS.

                  同样,我希望它在 GPS 关闭后立即开始监听来自网络的更新.

                  Similarly I want it to start listening for updates from network as soon as GPS is switched off.

                  这可能吗?

                  子问题

                  GPS 在提供位置定位方面与网络一样快吗?

                  Is GPS as fast as network in providing a location fix?

                  推荐答案

                  当然,您只需获取网络和 GPS 的提供程序,然后将您想要的任何一个传递给 locationManager.requestLocationUpdates().

                  Sure, you just get the providers for the network and GPS and pass whichever you want to locationManager.requestLocationUpdates().

                  当您想停止侦听某个提供程序时,请使用您在 locationManager.requestLocationUpdates() 中指定的侦听器对象调用 locationManager.removeUpdates().

                  When you want to stop listening to a certain provider, call locationManager.removeUpdates() with the listener object you specified in locationManager.requestLocationUpdates().

                  网络:

                  Criteria crit = new Criteria();
                  crit.setPowerRequirement(Criteria.POWER_LOW);
                  crit.setAccuracy(Criteria.ACCURACY_COARSE);
                  String provider = locationManager.getBestProvider(crit, false);
                  

                  全球定位系统:

                  Criteria crit2 = new Criteria();
                  crit2.setAccuracy(Criteria.ACCURACY_FINE);
                  provider2 = locationManager.getBestProvider(crit2, false);
                  

                  您可以使用 LocationManager.isProviderEnabled() 文档 查看是否启用/禁用了相应的提供程序.LocationManager 文档中提供了更多信息.

                  You can use LocationManager.isProviderEnabled() doc to see if the appropriate provider is enabled/disabled. There's more info available in the LocationManager docs.

                  GPS 通常比网络慢得多,因为您必须找到 3 颗以上遥远的卫星等.

                  GPS is usually much slower than network since you have to find 3+ far-away satellites, etc.

                  这篇关于在网络和 GPS 提供商之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 GeoPoint 转换为位置 下一篇:科尔多瓦地理定位精度上限为 10 米

                  相关文章

                  最新文章

                  <tfoot id='I4k7u'></tfoot>

                    <bdo id='I4k7u'></bdo><ul id='I4k7u'></ul>
                  1. <small id='I4k7u'></small><noframes id='I4k7u'>

                  2. <legend id='I4k7u'><style id='I4k7u'><dir id='I4k7u'><q id='I4k7u'></q></dir></style></legend>
                  3. <i id='I4k7u'><tr id='I4k7u'><dt id='I4k7u'><q id='I4k7u'><span id='I4k7u'><b id='I4k7u'><form id='I4k7u'><ins id='I4k7u'></ins><ul id='I4k7u'></ul><sub id='I4k7u'></sub></form><legend id='I4k7u'></legend><bdo id='I4k7u'><pre id='I4k7u'><center id='I4k7u'></center></pre></bdo></b><th id='I4k7u'></th></span></q></dt></tr></i><div id='I4k7u'><tfoot id='I4k7u'></tfoot><dl id='I4k7u'><fieldset id='I4k7u'></fieldset></dl></div>