androidtelephonytelephonymanagercdma

How can I get the country code for CDMA Android devices?


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:

Could these be used or are there better ones?


Solution

  • It works for CDMA, but not always - it depends on the network carrier.

    Here's an alternative idea, which suggests looking at the outgoing SMS or calls to figure out this device's phone number, from which you can then figure out the CountryIso based on the international dialing code...