flutter-geocoding icon indicating copy to clipboard operation
flutter-geocoding copied to clipboard

[Feature request]:On Android 13, ISO CountryCode is always empty

Open peng093 opened this issue 1 year ago • 1 comments

Is there already an issue requesting this feature?

Please select affected platform(s)

  • [X] Android
  • [X] iOS

Use case

countryCode=“”

Proposal

countryCode=“CN”

Specific requirements or considerations

No response

Additional information or context

No response

peng093 avatar Aug 27 '24 06:08 peng093

There is a similar problem in native Android, such as the United States, which previously returned US, but now returns "54003". If the plugin is written on the basis of native Android, I guess this is the reason

public static String getCountryCode(double lat,double lng) {
        Geocoder geocoder = new Geocoder(Utils.getContext(), Locale.getDefault());
        try {
            List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
            if (addresses.size() > 0) {
                Address address = addresses.get(0);
                // The numeric code returned in Android 13 is not the country number
                return address.getCountryCode();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }

peng093 avatar Aug 28 '24 00:08 peng093

Dear @peng093,

Thanks for the information. It is true that we only pass the information from the native side to the dart side. So I'll close this issue for now because we cannot change anything about this for now.

Kind regards,

TimHoogstrate avatar May 28 '25 07:05 TimHoogstrate