本文整理汇总了Java中com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType类的典型用法代码示例。如果您正苦于以下问题:Java PhoneNumberType类的具体用法?Java PhoneNumberType怎么用?Java PhoneNumberType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhoneNumberType类属于com.google.i18n.phonenumbers.PhoneNumberUtil包,在下文中一共展示了PhoneNumberType类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isTaggableDestination
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
public static boolean isTaggableDestination(Recipients recipients){
// Be safe - err on the side of not tagging
if (recipients.isGroupRecipient())
return false;
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
try {
PhoneNumber num = util.parse(recipients.getPrimaryRecipient().getNumber(),
Locale.getDefault().getCountry());
PhoneNumberType type = util.getNumberType(num);
Log.d(TAG, "Number type: " + type.toString());
return type == PhoneNumberType.FIXED_LINE ||
type == PhoneNumberType.MOBILE ||
type == PhoneNumberType.FIXED_LINE_OR_MOBILE;
}
catch (NumberParseException e){
Log.w(TAG, "Couldn't get number type (country: " + Locale.getDefault().getCountry() + ")");
return false;
}
}
开发者ID:SilenceIM,项目名称:Silence,代码行数:24,代码来源:AutoInitiate.java
示例2: assertNumberIsMobile
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
private void assertNumberIsMobile(String mobileNumber)
{
try
{
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
PhoneNumberType numberType = util.getNumberType(util.parse(mobileNumber, null));
if ((numberType != PhoneNumberType.MOBILE) && (numberType != PhoneNumberType.FIXED_LINE_OR_MOBILE))
{
throw InvalidDataException.notAMobileNumber(mobileNumber, numberType.toString());
}
}
catch (NumberParseException e)
{
throw YonaException.unexpected(e);
}
}
开发者ID:yonadev,项目名称:yona-server,代码行数:17,代码来源:UserService.java
示例3: onCreate
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_person_detail);
setupActionBar();
Locale locale = Locale.getDefault();
phoneNumberUtil = PhoneNumberUtil.getInstance();
PhoneNumber exampleNumber = phoneNumberUtil.getExampleNumberForType(locale.getCountry(), PhoneNumberType.FIXED_LINE);
System.out.println(phoneNumberUtil.format(exampleNumber, PhoneNumberFormat.NATIONAL));
System.out.println(exampleNumber.toString());
exampleNumber = phoneNumberUtil.getExampleNumberForType(locale.getCountry(), PhoneNumberType.MOBILE);
System.out.println(phoneNumberUtil.format(exampleNumber, PhoneNumberFormat.NATIONAL));
System.out.println(exampleNumber.toString());
if (savedInstanceState == null) {
Intent intent = getIntent();
long personId = intent.getLongExtra(PersonDetailController.ARG_PERSON_ID, -1);
Bundle args = new Bundle();
args.putLong(PersonDetailController.ARG_PERSON_ID, personId);
fragment = new PersonDetailFragment();
fragment.setArguments(args);
getSupportFragmentManager().beginTransaction()
.add(R.id.person_detail_container, fragment).commit();
} else {
fragment = (PersonDetailFragment) getSupportFragmentManager().findFragmentById(R.id.person_detail_container);
}
}
开发者ID:markuskreth,项目名称:ClubHelperAndroid,代码行数:35,代码来源:PersonDetailActivity.java
示例4: parse
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
public static ParsedPhoneNumber parse(String aNumber)
throws NumberParseException {
PhoneNumber number = null;
number = parse1(aNumber);
ParsedPhoneNumber parsedPhoneNumber = new ParsedPhoneNumber();
parsedPhoneNumber.setNumberValid(phoneUtil.isValidNumber(number));
PhoneNumberType type = phoneUtil.getNumberType(number);
parsedPhoneNumber.setMobile(PhoneNumberType.MOBILE.equals(type)
|| PhoneNumberType.FIXED_LINE_OR_MOBILE.equals(type));
parsedPhoneNumber
.setCountryCode(String.valueOf(number.getCountryCode()));
parsedPhoneNumber.setAlpha2Code(phoneUtil
.getRegionCodeForNumber(number));
String nationalSignificantNumber = phoneUtil
.getNationalSignificantNumber(number);
int geographicalAreaCodeLength = phoneUtil
.getLengthOfGeographicalAreaCode(number);
int nationalDestinationCodeLength = phoneUtil
.getLengthOfNationalDestinationCode(number);
String geographicalAreaCode = null;
String localNumber = nationalSignificantNumber;
if (geographicalAreaCodeLength > 0) {
geographicalAreaCode = nationalSignificantNumber.substring(0,
geographicalAreaCodeLength);
localNumber = nationalSignificantNumber
.substring(geographicalAreaCodeLength
+ nationalDestinationCodeLength);
}
parsedPhoneNumber.setAreaCode(geographicalAreaCode);
parsedPhoneNumber.setLocalNumber(localNumber);
return parsedPhoneNumber;
}
开发者ID:pengjieran,项目名称:OpenTools,代码行数:38,代码来源:PhoneNumberHelper.java
示例5: isMobileNumber
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
public static boolean isMobileNumber(String numberToParse) {
boolean result = false;
try {
PhoneNumber phoneNumber = parse1(numberToParse);
PhoneNumberType type = phoneUtil.getNumberType(phoneNumber);
if (PhoneNumberType.MOBILE.equals(type)
|| PhoneNumberType.FIXED_LINE_OR_MOBILE.equals(type)) {
result = true;
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
开发者ID:pengjieran,项目名称:OpenTools,代码行数:15,代码来源:PhoneNumberHelper.java
示例6: type_to_enum
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
private static PhoneNumberType type_to_enum( int type )
{
PhoneNumberType e = PhoneNumberType.UNKNOWN;
switch ( type )
{
case TYPE_FIXED_LINE:
e = PhoneNumberType.FIXED_LINE;
break;
case TYPE_MOBILE:
e = PhoneNumberType.MOBILE;
break;
case TYPE_FIXED_MOBILE:
e = PhoneNumberType.FIXED_LINE_OR_MOBILE;
break;
case TYPE_TOLL_FREE:
e = PhoneNumberType.TOLL_FREE;
break;
case TYPE_PREMIUM_RATE:
e = PhoneNumberType.PREMIUM_RATE;
break;
case TYPE_SHARED_COST:
e = PhoneNumberType.SHARED_COST;
break;
case TYPE_VOIP:
e = PhoneNumberType.VOIP;
break;
case TYPE_PERSONAL:
e = PhoneNumberType.PERSONAL_NUMBER;
break;
case TYPE_PAGER:
e = PhoneNumberType.PAGER;
break;
case TYPE_UAN:
e = PhoneNumberType.UAN;
break;
case TYPE_VOICEMAIL:
e = PhoneNumberType.VOICEMAIL;
break;
case TYPE_UNKNOWN:
default:
e = PhoneNumberType.UNKNOWN;
break;
}
return e;
}
开发者ID:nvanwyen,项目名称:libphonenumber-oracle,代码行数:59,代码来源:PhoneNumberImpl.java
示例7: enum_to_type
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
private static int enum_to_type( PhoneNumberType type )
{
int e = TYPE_UNKNOWN;
switch ( type )
{
case FIXED_LINE:
e = TYPE_FIXED_LINE;
break;
case MOBILE:
e = TYPE_MOBILE;
break;
case FIXED_LINE_OR_MOBILE:
e = TYPE_FIXED_MOBILE;
break;
case TOLL_FREE:
e = TYPE_TOLL_FREE;
break;
case PREMIUM_RATE:
e = TYPE_PREMIUM_RATE;
break;
case SHARED_COST:
e = TYPE_SHARED_COST;
break;
case VOIP:
e = TYPE_VOIP;
break;
case PERSONAL_NUMBER:
e = TYPE_PERSONAL;
break;
case PAGER:
e = TYPE_PAGER;
break;
case UAN:
e = TYPE_UAN;
break;
case VOICEMAIL:
e = TYPE_VOICEMAIL;
break;
case UNKNOWN:
default:
e = TYPE_UNKNOWN;
break;
}
return e;
}
开发者ID:nvanwyen,项目名称:libphonenumber-oracle,代码行数:59,代码来源:PhoneNumberImpl.java
示例8: getPhoneNumberType
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
private PhoneNumberType getPhoneNumberType(PhoneNumber phoneNumber) {
return phoneNumber != null ? PHONE_UTIL.getNumberType(phoneNumber) : null;
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:4,代码来源:PhoneUtil.java
示例9: isType
import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType; //导入依赖的package包/类
private boolean isType(PhoneNumberType type, Collection<PhoneNumberType> types) {
return types.contains(type);
}
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:4,代码来源:PhoneUtil.java
注:本文中的com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论