Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
peng093 opened this issue Aug 27, 2024 · 1 comment
Open
3 tasks done

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

peng093 opened this issue Aug 27, 2024 · 1 comment

Comments

@peng093
Copy link

peng093 commented Aug 27, 2024

Is there already an issue requesting this feature?

Please select affected platform(s)

  • Android
  • iOS

Use case

countryCode=“”

Proposal

countryCode=“CN”

Specific requirements or considerations

No response

Additional information or context

No response

@peng093 peng093 changed the title [Feature request]: countryCode 总是为空 [Feature request]:On Android 13, ISO CountryCode is always empty Aug 27, 2024
@peng093
Copy link
Author

peng093 commented Aug 28, 2024

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 "";
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant