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
- Telephony Manager
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
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()
- GPS
We doesn't want the Location permission to be requested
- Retrieving the Country details form the logged-in Google account
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
- IP address
We tried to get the IP of the Android device (from several IP fusion websites), there are following two cases
- User connected to WiFi - we are able to get the countryCode (WIFI IP : 64.134.234.17)
- User connected to Mobile Data - we are getting the wrong countryCode even we are in USA, it says that IP is from JAPAN (MOBILE NETWORK IP: 210.253.218.106)
Note: Even Netflix determine the country during the launch, without requesting the Location permission
http://freegeoip.net/json/
. You can give it a try if you already haven't . – Pomade