• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PhoneNumberType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Preconditions类代码示例发布时间:2022-05-22
下一篇:
Java Task类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap