How can I retrieve the country code information for Android devices under CDMA networks?
For all others, you can just use the TelephonyManager for that:
String countryCode = null;
TelephonyManager telMgr = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
if (telMgr.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA)
countryCode = telMgr.getNetworkCountryIso();
}
else {
// Now what???
}
I searched a bit, but I did not find any useful information that would lead to an answer.
Some ideas some to mind:
- GPS location: you can get the country from GeoCoder; and
- IP address: there are some nice APIs to get it, such as ipinfodb.
Could these be used or are there better ones?