Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Country code

Tags:

android

locale

I can get the country code in ISO-form using TelephonyManager::getNetworkCountryIso(), as it returns US for USA and such, but how can I get the numeric country dialing code?

I can't seem to find any functions provides me with the data I'm looking for, as I need a function that (for example) returns 01 for USA/Canada, 92 for Pakistan and so on.

like image 984
ARDaniyal Avatar asked Mar 03 '26 20:03

ARDaniyal


1 Answers

Since they're a short list, with a clear mapping to the alpha codes, could you perhaps just store a mapping?

I'm not sure this is what you want though, since the ISO numeric country code for Pakistan is 586 and your question quotes "92", which is the international dialing code for Pakistan. The same principle would work though.

like image 142
Jon Hanna Avatar answered Mar 05 '26 10:03

Jon Hanna