Reputation: 4560
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?
Upvotes: 3
Views: 2010
Reputation: 31
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/
Upvotes: 0
Reputation: 2718
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.
Upvotes: 4