Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Listing all country codes of phone numbers

I'd like to have the country code list for phone numbers. Such as, United State (+1), United Kingdom (+44) ... I know that libphonenumber is a great tool to help phone parsing, formatting and validation. However, it doesn't seem to have the functionality for listing all country codes. But those data should be within the metadata in libphonenumber, right? Does anyone have experience on this?

like image 929
ann Avatar asked May 29 '13 00:05

ann


1 Answers

I am an android developer. I am using the libphonenumber library along with java.util.Locale class to complete this as follows. It may be late response, but hope it helps someone like me in future.

Set<String> set = PhoneNumberUtil.getInstance().getSupportedRegions();  String[] arr = set.toArray(new String[set.size()]);  for (int i = 0; i < arr.size(); i++) {     Locale locale = new Locale("en", arr[i]);     Log.d(TAG, "lib country:" + arr[i] + "  "+ locale.getDisplayCountry()); } 
like image 101
Ram Avatar answered Sep 18 '22 01:09

Ram