-1

I am actively looking at google api's and I have reached nowhere where google can provide me Country name or Country code under following condition :

1. GPS disabled

2. Location services disabled

Also I got this post Google API for location, based on user IP address

Now read 2nd answer please go to the first link the user has provided.

Community
  • 1
  • 1
SamH67
  • 319
  • 1
  • 4
  • 14

1 Answers1

0

According to your given conditions, you can use Sim Card to find user's current country.

Following method will give you current country of the user

 getNetworkCountryIso()

Returns the ISO country code equivalent of the current registered operator's MCC (Mobile Country Code).

Usage:

String country = android.telephony.TelephonyManager.getNetworkCountryIso();
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
  • I have already done and executed successfully but problem is my insisting on using google api because in case of no sim card but he is ready to verify from other phones and phone in which the app is installed has no sim card then this case will not work – SamH67 Jan 31 '17 at 12:36
  • edit that you suggested is wrong as that method will return the country of the sim card origin not user current country. – Vivek Mishra Jan 31 '17 at 12:43
  • Okay but do you know any way to resolve the above issue – SamH67 Jan 31 '17 at 13:12
  • as far as I know if there will be some api, then it would require atleast location services to fetch country. – Vivek Mishra Jan 31 '17 at 13:14
  • but open your browser and if you turn off that location pop in mozilla firefox it still get country try plsss – SamH67 Jan 31 '17 at 13:21
  • and try use this link – SamH67 Jan 31 '17 at 13:22
  • your link gave this in my browser {"ip":"192.168.20.89","country_code":"","country_name":"","region_code":"","region_name":"","city":"","zip_code":"","time_zone":"","latitude":0,"longitude":0,"metro_code":0} – Vivek Mishra Jan 31 '17 at 13:22
  • I got {"ip":"180.233.120.122","country_code":"IN","country_name":"India","region_code":"","region_name":"","city":"","zip_code":"","time_zone":"Asia/Kolkata","latitude":20,"longitude":77,"metro_code":0} – SamH67 Jan 31 '17 at 13:23
  • But how this is picking my location – SamH67 Jan 31 '17 at 13:24
  • may be from cache or cookies – Vivek Mishra Jan 31 '17 at 13:24
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/134485/discussion-between-vivek-mishra-and-samh67). – Vivek Mishra Jan 31 '17 at 13:28