In my android app I need to get the country, but I can't depend on GPS and Google services as both aren't supported in China. I have tried other methods and nothing works well. Anybody have any other ideas?
Asked
Active
Viewed 818 times
0
-
1try this: http://stackoverflow.com/questions/12210696/how-to-get-country-or-its-iso-code – Deepak Sachdeva Nov 29 '16 at 12:18
-
Try to use TelephonyManager to get country code of install sim card and by this country code find your country – Sanwal Singh Nov 29 '16 at 12:20
-
I tried Locale and telephone manager too. But it is not accurate – Cecil Paul Nov 29 '16 at 12:20
-
@Shane. It wont work with th people who are travelling with same sim arround the globe – Cecil Paul Nov 29 '16 at 12:22
-
1@CecilPaul Its very hard to find the country without GPS and google service .TelephonyManager won't work if there is no sim in your phone.And Locale won't work if the user in china set his language as English .If your app requires internet connection then there is an option. Use this api http://ip-api.com/json .But go through there documentation 1st ,if you are planing to use this – Sunil Sunny Nov 29 '16 at 12:29
1 Answers
3
Since its a very long comment I will post this as an answer for easy visibility.
Its very hard to find the country without GPS and google service .TelephonyManager won't work if there is no sim in your phone.And Locale won't work if the user in china set his language as English (Means the country you will be getting will be US or UK).If your app requires internet connection then there is an option. Use this api ip-api .But go through there documentation 1st ,if you are planing to use this http://ip-api.com/docs/
There are other api's like this freegeoip api but like you said not sure if it is blocked in china..

Sunil Sunny
- 3,949
- 4
- 23
- 53
-
I tried that too. I think that url is blocked in China. Its not getting open even. And also sometimes it shows Us when we open this url in India – Cecil Paul Nov 30 '16 at 03:55
-
What is in the drive ? Did you tried the freegeo api as well.. see my edit – Sunil Sunny Nov 30 '16 at 04:59
-
A screen shot of the result ip-api.com result when called from India – Cecil Paul Nov 30 '16 at 05:01
-
mm it 's strange ,for me it's always giving the correct country.Anyway you cannot trust it complety since it's a 3rd pary api. – Sunil Sunny Nov 30 '16 at 05:05