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
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.
You can (and should) use Android's country detector service. The service consists of three methods, all defined in their .aidl, which enable you to get the country code, register a listener, or remove it. Specifically, you want the first - Country detectCountry();
which returns an android.location.Country object (frameworks/base/location/java/android/location/Country.java in the AOSP). I'm assuming you know how to call methods programmatically (you'll need getSystemService ("country_detector")).
To test from the command line, try:
shell@flounder:/ $ service call country_detector 1
Result: Parcel(
0x00000000: 00000000 00000001 00000002 00530055 '............U.S.'
0x00000010: 00000000 00000003 1d809dda 00000000 '................')
The object serialization is basically nothing more than the 2 letter country code (here: US), the source (here, 3, implying this was gleaned from the Locale), and a timestamp (1d809dda...) which really isn't that important. You don't have to worry about serialization since the object is Parcelable.
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": ""
}