本文整理匯總了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;
}