getNameForValidNumber method

String getNameForValidNumber(
  1. PhoneNumber number,
  2. Locale languageCode
)

Returns a carrier name for the given phone number, in the language provided. The carrier name is the one the number was originally allocated to, however if the country supports mobile number portability the number might not belong to the returned carrier anymore. If no mapping is found an empty string is returned.

This method assumes the validity of the number passed in has already been checked, and that the number is suitable for carrier lookup. We consider mobile and pager numbers possible candidates for carrier lookup.

param number a valid phone number for which we want to get a carrier name param languageCode the language code in which the name should be written returns a carrier name for the given phone number

Implementation

String getNameForValidNumber(PhoneNumber number, Locale languageCode) {
  String langStr = languageCode.language;
  String scriptStr = ""; // No script is specified
  String regionStr = languageCode.country;
  return _prefixFileReader.getDescriptionForNumber(
      number, langStr, scriptStr, regionStr);
}