getSafeDisplayName method
Gets the name of the carrier for the given phone number only when it is 'safe' to display to users. A carrier name is considered safe if the number is valid and for a region that doesn't support mobile number portability.
number
the phone number for which we want to get a carrier name
languageCode
the language code in which the name should be written
returns a carrier name that is safe to display to users, or the empty string
Implementation
String getSafeDisplayName(PhoneNumber number, Locale languageCode) {
if (_phoneUtil.isMobileNumberPortableRegion(
_phoneUtil.getRegionCodeForNumber(number))) {
return "";
}
return getNameForNumber(number, languageCode);
}