Java Code Examples for com.google.i18n.phonenumbers.NumberParseException#printStackTrace()
The following examples show how to use
com.google.i18n.phonenumbers.NumberParseException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From Android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance(); Phonenumber.PhoneNumber indianPhoneNumber = null; try { indianPhoneNumber = phoneNumberUtil.parse(phoneNumber, "IN"); boolean val = phoneNumberUtil.isValidNumber(indianPhoneNumber); Log.d("Parzival", "Data: "+indianPhoneNumber.getCountryCode()+" >> "+indianPhoneNumber.getNationalNumber()); Log.d("Parzival", "Val: "+val); } catch (NumberParseException e) { e.printStackTrace(); } }
Example 2
Source File: ContactFragment.java From customview-samples with Apache License 2.0 | 6 votes |
private void displayContactData(){ List<PhoneInfo> phoneInfoList = MobileContactSingleton.getInstance().getMobileContact(); PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); for(PhoneInfo phoneInfo: phoneInfoList) { try { String phoneNum = phoneInfo.getPhoneNum(); Phonenumber.PhoneNumber phoneNumProto = phoneUtil.parse(phoneNum, "CN"); boolean isValid = phoneUtil.isValidNumber(phoneNumProto); Log.d("hyh", "ContactFragment: displayContactData: isValid="+isValid+" ,phoneNum="+phoneNum); if (isValid) { String formatPhoneNum = phoneUtil.format(phoneNumProto, PhoneNumberUtil.PhoneNumberFormat.E164); Log.d("hyh", "ContactMgr: run: formatPhoneNum=" + formatPhoneNum); } } catch (NumberParseException e) { Log.d("hyh", "ContactFragment: displayContactData: phone="+phoneInfo.getPhoneNum()); e.printStackTrace(); } } ContactListAdapter contactListAdapter = new ContactListAdapter(getContext(),phoneInfoList); mRvContactList.setLayoutManager(new LinearLayoutManager(getContext())); mRvContactList.setAdapter(contactListAdapter); }
Example 3
Source File: SignIn.java From XERUNG with Apache License 2.0 | 6 votes |
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); } } }
Example 4
Source File: SignIn.java From XERUNG with Apache License 2.0 | 6 votes |
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); } } }
Example 5
Source File: CountryMaster.java From XERUNG with Apache License 2.0 | 5 votes |
/** * 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; }
Example 6
Source File: CountryMaster.java From XERUNG with Apache License 2.0 | 5 votes |
/** * 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; }
Example 7
Source File: LinkChangePhoneActivity.java From Android with MIT License | 5 votes |
@Override public void afterTextChanged(Editable s) { try { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); Phonenumber.PhoneNumber swissNumberProto = phoneUtil.parse(s.toString(), countryBean.getCountryCode()); if(phoneUtil.isValidNumberForRegion(swissNumberProto, countryBean.getCountryCode())){ nextBtn.setEnabled(true); }else{ nextBtn.setEnabled(false); } } catch (NumberParseException e) { e.printStackTrace(); nextBtn.setEnabled(false); } }