• <small id='SsS2g'></small><noframes id='SsS2g'>

    <legend id='SsS2g'><style id='SsS2g'><dir id='SsS2g'><q id='SsS2g'></q></dir></style></legend>

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

      1. 如何在android中获取移动设备的经纬度?

        时间:2023-09-30
        <tfoot id='lJ4rW'></tfoot><legend id='lJ4rW'><style id='lJ4rW'><dir id='lJ4rW'><q id='lJ4rW'></q></dir></style></legend>

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

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

              <tbody id='lJ4rW'></tbody>

                <bdo id='lJ4rW'></bdo><ul id='lJ4rW'></ul>
                • 本文介绍了如何在android中获取移动设备的经纬度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何使用定位工具在android中获取移动设备的当前纬度和经度?

                  How do I get the current Latitude and Longitude of the mobile device in android using location tools?

                  推荐答案

                  使用 LocationManager.

                  LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); 
                  Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                  double longitude = location.getLongitude();
                  double latitude = location.getLatitude();
                  

                  getLastKnownLocation() 的调用不会阻塞 - 这意味着如果当前没有可用位置,它将返回 null - 所以你可能想看看将 LocationListener 传递给 requestLocationUpdates() 方法,它将为您提供位置的异步更新.

                  The call to getLastKnownLocation() doesn't block - which means it will return null if no position is currently available - so you probably want to have a look at passing a LocationListener to the requestLocationUpdates() method instead, which will give you asynchronous updates of your location.

                  private final LocationListener locationListener = new LocationListener() {
                      public void onLocationChanged(Location location) {
                          longitude = location.getLongitude();
                          latitude = location.getLatitude();
                      }
                  }
                  
                  lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);
                  

                  您需要为您的应用程序提供 ACCESS_FINE_LOCATION 权限 如果你想使用 GPS.

                  You'll need to give your application the ACCESS_FINE_LOCATION permission if you want to use GPS.

                  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
                  

                  您可能还想添加 ACCESS_COARSE_LOCATION 当 GPS 不可用时的权限 并使用 getBestProvider() 方法.

                  You may also want to add the ACCESS_COARSE_LOCATION permission for when GPS isn't available and select your location provider with the getBestProvider() method.

                  这篇关于如何在android中获取移动设备的经纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:SQlite 获取最近的位置(经纬度) 下一篇:在 Java 中获取地理位置的最佳方法

                  相关文章

                  最新文章

                • <tfoot id='Sy2PY'></tfoot><legend id='Sy2PY'><style id='Sy2PY'><dir id='Sy2PY'><q id='Sy2PY'></q></dir></style></legend>

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

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