我无法使用网络提供商获取我的位置?但它始终启用

时间:2014-02-14 10:26:15

标签: android locationmanager android-location

if (isNetworkEnabled) {
                locationManagers.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network");
                if (locationManagers != null) {
                    location = locationManagers.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();

                        Geocoder geocoder;
                        List<Address> addresses;
                        geocoder = new Geocoder(this, Locale.getDefault());
                        addresses = geocoder.getFromLocation(latitude, longitude, 1);

                        address = addresses.get(0).getAddressLine(0);
                        //                              String city = addresses.get(0).getAddressLine(1);
                        //                              String country = addresses.get(0).getAddressLine(2);
                    }
                }
            }

上面是我获取位置的代码。它之前运作良好。但今天我突然检查它不会得到任何位置。在这一点上跳过了requestLocationUpdates()。我不知道实际问题在哪里...我用wifi来获取位置update.i检查了所有的设置。

0 个答案:

没有答案