android - Geocoder.getFromLocationName() is not working in ICS device

前端 未结 2 1247
温柔的废话
温柔的废话 2021-02-20 08:30

I have two devices. One is HTC WildFire S and other one is HTC 1V. I used the Geocoder.getFromLocationName() in my application. It

相关标签:
2条回答
  • 2021-02-20 09:06
      GeoPoint point = new GeoPoint(
                            (int) (LATITUDE * 1E6),
                            (int) (LONGITUDE * 1E6));
    
    String n;
    
    public void someRandomMethod() {
            n = convertPointToLocation(point);
    }
    
    
    
    public String convertPointToLocation(GeoPoint point) {
            String address = "";
            Geocoder geoCoder = new Geocoder(
                    getBaseContext(), Locale.getDefault());
            try {
                List<Address> addresses = geoCoder.getFromLocation(
                        point.getLatitudeE6()  / 1E6,
                        point.getLongitudeE6() / 1E6, 1);
    
                if (addresses.size() > 0) {
                    for (int index = 0; index < addresses.get(0).getMaxAddressLineIndex(); index++)
                        address += addresses.get(0).getAddressLine(index) + " ";
                }
            }
            catch (IOException e) {
                e.printStackTrace();
            }
    
            return address;
        }
    
    0 讨论(0)
  • 2021-02-20 09:11

    Finally i found the answer :https://code.google.com/p/android/issues/detail?id=38009

    Reboot your device for Geocoder to work. Hope it helps someone

    Note: some say it will work if you use Google API 16

    0 讨论(0)
提交回复
热议问题