I need to determine the national carrier code (not the country code) of any phone number, using libphonenumber Java SDK. How can I do this?
Asked
Active
Viewed 1,662 times
2 Answers
4
This should help your case - PhoneNumberToCarrierMapper
In the PhoneNumberToCarrierMapper
class there is a method:
String getNameForValidNumber(PhoneNumber number, Locale languageCode)
This should give your the carrier code.
You can see the source code of that method in the related GitHub repository here.

informatik01
- 16,038
- 10
- 74
- 104

Srikanth Balaji
- 2,638
- 4
- 18
- 31
-
I don't have that class. I'm using libphonenumber-7.7.5.jar – RedEagle Feb 20 '17 at 12:26
-
You need carrier jar - you can use from here , http://repo1.maven.org/maven2/com/googlecode/libphonenumber/carrier/1.10/ – Srikanth Balaji Feb 21 '17 at 01:57
-
Worked perfectly... Thanks – RedEagle Feb 27 '17 at 01:15
0
libphonenumber-8.13.6 doesn't seem to come packaged with PhoneNumberToCarrierMapper class. The import will not work for com.google.i18n.phonenumbers.PhoneNumberToCarrierMapper
I had to add a separate jar to my build path to get this class to successfully import. If you are using maven, you would just need to add a new dependency to your pom file.
https://repo1.maven.org/maven2/com/googlecode/libphonenumber/carrier/

Ramster
- 31
- 1
- 3