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

  • <tfoot id='0n5ot'></tfoot>

    1. <legend id='0n5ot'><style id='0n5ot'><dir id='0n5ot'><q id='0n5ot'></q></dir></style></legend>
    2. <small id='0n5ot'></small><noframes id='0n5ot'>

      • <bdo id='0n5ot'></bdo><ul id='0n5ot'></ul>

      1. 在不使用 GPS 或互联网的情况下获取用户在 Andr

        时间:2023-09-02

          <legend id='VmIyF'><style id='VmIyF'><dir id='VmIyF'><q id='VmIyF'></q></dir></style></legend>
          • <bdo id='VmIyF'></bdo><ul id='VmIyF'></ul>
            • <tfoot id='VmIyF'></tfoot>

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

                    <tbody id='VmIyF'></tbody>

                  本文介绍了在不使用 GPS 或互联网的情况下获取用户在 Android 中的当前位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  是否可以在不使用 GPS 或互联网的情况下获取用户的当前位置?我的意思是在移动网络提供商的帮助下.

                  Is it possible to get the current location of user without using GPS or the internet? I mean with the help of mobile network provider.

                  推荐答案

                  你要做的是使用 LocationManager.NETWORK_PROVIDER 而不是 LocationManager.GPS_PROVIDER.NETWORK_PROVIDER 将在可用的 GSM 或 wifi 上解析.显然,在关闭 wifi 的情况下,将使用 GSM.请记住,使用蜂窝网络基本上可以精确到 500m.

                  What you are looking to do is get the position using the LocationManager.NETWORK_PROVIDER instead of LocationManager.GPS_PROVIDER. The NETWORK_PROVIDER will resolve on the GSM or wifi, which ever available. Obviously with wifi off, GSM will be used. Keep in mind that using the cell network is accurate to basically 500m.

                  http://developer.android.com/guide/topics/location/obtaining-user-location.html 有一些非常棒的信息和示例代码.

                  http://developer.android.com/guide/topics/location/obtaining-user-location.html has some really great information and sample code.

                  在完成OnCreate() 中的大部分代码后,添加以下代码:

                  After you get done with most of the code in OnCreate(), add this:

                  // Acquire a reference to the system Location Manager
                  LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
                  
                  // Define a listener that responds to location updates
                  LocationListener locationListener = new LocationListener() {
                      public void onLocationChanged(Location location) {
                        // Called when a new location is found by the network location provider.
                        makeUseOfNewLocation(location);
                      }
                  
                      public void onStatusChanged(String provider, int status, Bundle extras) {}
                  
                      public void onProviderEnabled(String provider) {}
                  
                      public void onProviderDisabled(String provider) {}
                    };
                  
                  // Register the listener with the Location Manager to receive location updates
                  locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
                  

                  您还可以让您的活动实现 LocationListener 类,从而在您的活动中实现 onLocationChanged().

                  You could also have your activity implement the LocationListener class and thus implement onLocationChanged() in your activity.

                  这篇关于在不使用 GPS 或互联网的情况下获取用户在 Android 中的当前位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:android webview 地理定位 下一篇:计算距离一个坐标的新坐标 x 米和 y 度

                  相关文章

                  最新文章

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

                    <small id='7yU5P'></small><noframes id='7yU5P'>

                    <legend id='7yU5P'><style id='7yU5P'><dir id='7yU5P'><q id='7yU5P'></q></dir></style></legend>

                    1. <tfoot id='7yU5P'></tfoot>