Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically detect in which country the android device is located currently without using GPS?

Tags:

java

android

When my app runs, I want to detect the current location's country name and do some stuff for that specific country name, I can easily do it using geocoder, gps. But I want to get it from Locale or if anything more is available.

like image 220
Reyjohn Avatar asked May 25 '12 13:05

Reyjohn


2 Answers

Use this link http://ip-api.com/json ,this will provide all the information as json. From this json you can get the country easily. This site works using your current IP,it automatically detects the IP and sendback details.

Docs http://ip-api.com/docs/api:json Hope it helps.

This is what I got.

{
"as": "AS55410 C48 Okhla Industrial Estate, New Delhi-110020",
"city": "Kochi",
"country": "India",
"countryCode": "IN",
"isp": "Vodafone India",
"lat": 9.9667,
"lon": 76.2333,
"org": "Vodafone India",
"query": "123.63.81.162",
"region": "KL",
"regionName": "Kerala",
"status": "success",
"timezone": "Asia/Kolkata",
"zip": ""

}

like image 134
shine_joseph Avatar answered Sep 20 '22 00:09

shine_joseph


I dont know if Android API allowes you to check the Provider Code of the associated GSM Network. If this is possible you could use this Code an check i.e. against this List : http://www.techgsm.com/page/gsm-provider-codes/network-provider-identify-codes.html to find out in which country the Cellphone is.

like image 45
spot Avatar answered Sep 18 '22 00:09

spot