• <legend id='qSUom'><style id='qSUom'><dir id='qSUom'><q id='qSUom'></q></dir></style></legend>

    • <bdo id='qSUom'></bdo><ul id='qSUom'></ul>

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

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

      <tfoot id='qSUom'></tfoot>
      1. 如何在android中获取移动设备的经纬度?

        How to get Latitude and Longitude of the mobile device in android?(如何在android中获取移动设备的经纬度?)

      2. <small id='dZ7Bw'></small><noframes id='dZ7Bw'>

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

          • <legend id='dZ7Bw'><style id='dZ7Bw'><dir id='dZ7Bw'><q id='dZ7Bw'></q></dir></style></legend>

              <bdo id='dZ7Bw'></bdo><ul id='dZ7Bw'></ul>
                <tbody id='dZ7Bw'></tbody>

                  本文介绍了如何在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中获取移动设备的经纬度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                      <tbody id='RMtVF'></tbody>
                    <i id='RMtVF'><tr id='RMtVF'><dt id='RMtVF'><q id='RMtVF'><span id='RMtVF'><b id='RMtVF'><form id='RMtVF'><ins id='RMtVF'></ins><ul id='RMtVF'></ul><sub id='RMtVF'></sub></form><legend id='RMtVF'></legend><bdo id='RMtVF'><pre id='RMtVF'><center id='RMtVF'></center></pre></bdo></b><th id='RMtVF'></th></span></q></dt></tr></i><div id='RMtVF'><tfoot id='RMtVF'></tfoot><dl id='RMtVF'><fieldset id='RMtVF'></fieldset></dl></div>
                  1. <small id='RMtVF'></small><noframes id='RMtVF'>

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

                          <bdo id='RMtVF'></bdo><ul id='RMtVF'></ul>
                          <tfoot id='RMtVF'></tfoot>