反向地理编码在调试模式下工作,但在运行模式下不工作

时间:2011-09-20 15:03:04

标签: java android

我有一个与Android中的地理编码有关的非常奇怪的情况。我有一个班级,我可以找到纬度和经度信息,并使用基于位置的服务将其转换为地址信息。

应用程序在调试模式下工作正常,其中x,y对被转换为地址信息,但是当我在运行模式下运行应用程序时(当我以常规方式运行时),转换始终为NULL。

你以前遇到过这样的情况吗?如果是,可能导致此类问题的原因是什么?

纬度,经度对的代码段

 mostRecentLocation = locationManager.getLastKnownLocation(locationProvider);
        if(mostRecentLocation != null) { //Update with New Location
            lat = mostRecentLocation.getLatitude();
            lng = mostRecentLocation.getLongitude();
            currentLocationURL = "http://maps.google.com/?q=" + lat + "," + lng; //Construct URL
        } else {
            currentLocationURL = "No Location Found";
        }

X,Y到地址信息的翻译,

 addresses = gc.getFromLocation(lat, lng, 1);
            StringBuilder sb = new StringBuilder();
            if (addresses.size() > 0) {
                Address address = addresses.get(0);
                for (int i = 0; i < address.getMaxAddressLineIndex(); i++)
                    sb.append(address.getAddressLine(i)).append("\n");
                    sb.append(address.getLocality()).append("\n");
                    sb.append(address.getPostalCode()).append("\n");
                    sb.append(address.getCountryName());
            addressString = sb.toString();

0 个答案:

没有答案
相关问题