Our intention is to filter the content based on location without requesting Location permission from the Android device,
In-order to meet this requirement, we have tried the following options and still its not reliable
it wont work without a Sim card, again say if the user from USA travels india now the below snippets returns US not India
var telephonyManager = context?.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
val countryCodeValue = telephonyManager.networkCountryIso
Locale returns US or UK by default even if they are in India, usually user's Locale would be in English by default
Locale.getDefault().getCountry()
We doesn't want the Location permission to be requested
Reply from Google - They dont have any dedicated API to retrieve countryCode of an user Note: iOS has a dedicated API which tell the CountryCode of the user, but Android doesn't
We tried to get the IP of the Android device (from several IP fusion websites), there are following two cases
Note: Even Netflix determine the country during the launch, without requesting the Location permission
TELEPHONY_SERVICE); String countryCode = tm. getSimCountryIso();
Though GB is the United Kingdom's ISO 3166-1 alpha-2 code, UK is exceptionally reserved for the United Kingdom on the request of the country. Its main usage is the . uk internet ccTLD and, on 28 September 2021, UK replaced GB as the official country code on car registration plates.
United States Country Code 1 Country Code US.
I think you have only two possibilities...or ask permission...or without asking permission you have to ask the user to insert an address (also only the city) and retrive the country code by mean of Google Geocoding Service
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With