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
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.