本文整理汇总了Java中com.google.i18n.phonenumbers.NumberParseException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java NumberParseException.printStackTrace方法的具体用法?Java NumberParseException.printStackTrace怎么用?Java NumberParseException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.i18n.phonenumbers.NumberParseException
的用法示例。
在下文中一共展示了NumberParseException.printStackTrace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendOTPNumber
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
private void sendOTPNumber(){
if(checkNull()){
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
// assuming you only a button in your layout...
boolean isAuthentic = false;
try {
PhoneNumber number = util.parse(countryPrefix + edtMobile.getText().toString().trim(), countryIso);
isAuthentic = true;
} catch (NumberParseException e) {
e.printStackTrace();
}
if (isAuthentic) {
comman.hideSoftKeyBoard(context, edtMobile);
createJson(edtMobile.getText().toString().trim(), countryPrefix, countryName);
}
}
}
示例2: isValidNumberInE164Format
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
public boolean isValidNumberInE164Format(String number) {
final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
Phonenumber.PhoneNumber phoneNumber = null;
int country;
try {
phoneNumber = phoneNumberUtil.parse(number, "");
country = phoneNumber.getCountryCode();
} catch (NumberParseException e) {
e.printStackTrace();
return false;
}
return phoneNumberUtil.isValidNumberForRegion(phoneNumber,
phoneNumberUtil.getRegionCodeForCountryCode(country));
}
示例3: getPhoneNumber
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
/**
* Uses libphonenumber library to fetch a {@link PhoneNumber} object, from
* a full phone number inclusive of country telephone prefix. Works best
* by supplying a string without plus and hyphen characters in my experience.
*
* @param phoneNumber String
* @return number {@link PhoneNumber}
*
* @see <a href="https://github.com/googlei18n/libphonenumber">https://github.com/googlei18n/libphonenumber</a>
*/
public PhoneNumber getPhoneNumber(String phoneNumber) {
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
PhoneNumber number = null;
try {
number = util.parse(phoneNumber, getDefaultCountryIso());
} catch (NumberParseException e) {
e.printStackTrace();
}
return number;
}
示例4: validatePhone
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
public static boolean validatePhone(String phone) {
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
Phonenumber.PhoneNumber number = phoneUtil.parse(phone, Locale.getDefault().getCountry());
return phoneUtil.isValidNumber(number);
} catch(NumberParseException e) {
e.printStackTrace();
return false;
}
}
示例5: sanitizeNumber
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
/**
* Santizies a phone number, stripping out any extensions and country codes.
*
* WARNING: If you then try to send a text to this number (and it was international),
* the text will not send. The country code was stripped out.
*/
private String sanitizeNumber(String phoneNumber) {
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
Phonenumber.PhoneNumber numberProto = phoneUtil.parse(phoneNumber, Locale.getDefault().getCountry());
return Long.toString(numberProto.getNationalNumber());
} catch (NumberParseException e) {
e.printStackTrace();
}
return phoneNumber;
}
示例6: internationalNumber
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
/**
* Private Section
*/
public String internationalNumber(String strPhoneNumber, String strDefaultRegion) {
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
PhoneNumber phoneNumber = new PhoneNumber();
try {
phoneNumber = phoneUtil.parse(strPhoneNumber, strDefaultRegion);
} catch (NumberParseException e) {
e.printStackTrace();
}
strPhoneNumber = phoneUtil.format(phoneNumber, PhoneNumberUtil.PhoneNumberFormat.INTERNATIONAL);
main.Status.print("Changed to international number format: " + strPhoneNumber);
return strPhoneNumber;
}
示例7: isValidPhoneNumber
import com.google.i18n.phonenumbers.NumberParseException; //导入方法依赖的package包/类
public static boolean isValidPhoneNumber(String number) {
boolean result = false;
try {
PhoneNumber phoneNumber = parse1(number);
result = phoneUtil.isValidNumber(phoneNumber);
} catch (NumberParseException e) {
e.printStackTrace();
}
return result;
}