List of usage examples for android.telephony PhoneNumberUtils isGlobalPhoneNumber
public static boolean isGlobalPhoneNumber(String phoneNumber)
From source file:Main.java
public static boolean isPhoneValid(String phone) { return PhoneNumberUtils.isGlobalPhoneNumber(phone); // return true; }
From source file:Main.java
public final static boolean isValidPhoneNumber(String number) { if (number == null) { return false; } else {/*from ww w . j a v a 2s . co m*/ return PhoneNumberUtils.isGlobalPhoneNumber(number); } }
From source file:Main.java
public static boolean isMobileNo(String mobileNo) { return PhoneNumberUtils.isGlobalPhoneNumber(mobileNo); }
From source file:com.geniusgithub.contact.contact.calllog.ContactInfoHelper.java
/** * Returns the contact information for the given number. * <p>/* www . java2s . com*/ * If the number does not match any contact, returns a contact info containing only the number * and the formatted number. * <p> * If an error occurs during the lookup, it returns null. * * @param number the number to look up * @param countryIso the country associated with this number */ public ContactInfo lookupNumber(String number, String countryIso) { final ContactInfo info; // Determine the contact info. if (PhoneNumberHelper.isUriNumber(number)) { // This "number" is really a SIP address. ContactInfo sipInfo = queryContactInfoForSipAddress(number); if (sipInfo == null || sipInfo == ContactInfo.EMPTY) { // Check whether the "username" part of the SIP address is // actually the phone number of a contact. String username = PhoneNumberHelper.getUsernameFromUriNumber(number); if (PhoneNumberUtils.isGlobalPhoneNumber(username)) { sipInfo = queryContactInfoForPhoneNumber(username, countryIso); } } info = sipInfo; } else { // Look for a contact that has the given phone number. ContactInfo phoneInfo = queryContactInfoForPhoneNumber(number, countryIso); if (phoneInfo == null || phoneInfo == ContactInfo.EMPTY) { // Check whether the phone number has been saved as an "Internet call" number. phoneInfo = queryContactInfoForSipAddress(number); } info = phoneInfo; } final ContactInfo updatedInfo; if (info == null) { // The lookup failed. updatedInfo = null; } else { // If we did not find a matching contact, generate an empty contact info for the number. if (info == ContactInfo.EMPTY) { // Did not find a matching contact. updatedInfo = new ContactInfo(); updatedInfo.number = number; updatedInfo.formattedNumber = formatPhoneNumber(number, null, countryIso); updatedInfo.normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso); updatedInfo.lookupUri = createTemporaryContactUri(updatedInfo.formattedNumber); } else { updatedInfo = info; } } return updatedInfo; }
From source file:com.android.dialer.calllog.ContactInfoHelper.java
/** * Returns the contact information for the given number. * <p>/*from w ww . j av a 2 s .c om*/ * If the number does not match any contact, returns a contact info containing only the number * and the formatted number. * <p> * If an error occurs during the lookup, it returns null. * * @param number the number to look up * @param countryIso the country associated with this number */ public ContactInfo lookupNumber(String number, String countryIso) { if (TextUtils.isEmpty(number)) { return null; } final ContactInfo info; // Determine the contact info. if (PhoneNumberHelper.isUriNumber(number)) { // This "number" is really a SIP address. ContactInfo sipInfo = queryContactInfoForSipAddress(number); if (sipInfo == null || sipInfo == ContactInfo.EMPTY) { // Check whether the "username" part of the SIP address is // actually the phone number of a contact. String username = PhoneNumberHelper.getUsernameFromUriNumber(number); if (PhoneNumberUtils.isGlobalPhoneNumber(username)) { sipInfo = queryContactInfoForPhoneNumber(username, countryIso); } } info = sipInfo; } else { // Look for a contact that has the given phone number. ContactInfo phoneInfo = queryContactInfoForPhoneNumber(number, countryIso); if (phoneInfo == null || phoneInfo == ContactInfo.EMPTY) { // Check whether the phone number has been saved as an "Internet call" number. phoneInfo = queryContactInfoForSipAddress(number); } info = phoneInfo; } final ContactInfo updatedInfo; if (info == null) { // The lookup failed. updatedInfo = null; } else { // If we did not find a matching contact, generate an empty contact info for the number. if (info == ContactInfo.EMPTY) { // Did not find a matching contact. updatedInfo = new ContactInfo(); updatedInfo.number = number; updatedInfo.formattedNumber = formatPhoneNumber(number, null, countryIso); updatedInfo.normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso); updatedInfo.lookupUri = createTemporaryContactUri(updatedInfo.formattedNumber); } else { updatedInfo = info; } } return updatedInfo; }
From source file:org.cryptocall.ui.WizardActivity.java
/** * Checks if text of given EditText contains a valid international telephone number. If not an * error is set and the EditText gets the focus. * // w w w . j a va 2 s . com * @param context * @param editText * @return true if valid telephone number */ private static boolean isEditTextValidTelephoneNumber(Context context, EditText editText) { boolean output = true; if (!PhoneNumberUtils.isWellFormedSmsAddress(editText.getText().toString())) { editText.setError(context.getString(R.string.wizard_error_blank)); editText.requestFocus(); output = false; } else { if (!editText.getText().toString().startsWith("+") || !PhoneNumberUtils.isGlobalPhoneNumber(editText.getText().toString())) { editText.setError(context.getString(R.string.wizard_error_not_international)); editText.requestFocus(); output = false; } else { editText.setError(null); } } return output; }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
/** New Feature */ public static boolean checkSimNumberValid(Activity activity, String ssp) { if (ssp != null && !PhoneNumberUtils.isGlobalPhoneNumber(ssp)) { Toast.makeText(activity.getApplicationContext(), R.string.sim_invalid_number, Toast.LENGTH_SHORT) .show();/*from ww w . ja v a2 s. co m*/ activity.finish(); return true; } return false; }
From source file:com.beza.briver.fragments.ProfileFragment.java
public boolean validateProfileChangeInfo() { boolean valid = true; if (profileFullName.trim().isEmpty()) { etProfileFullName.setError("Empty"); valid = false;//from ww w . j a v a2s . c o m } else if (profileFullName.trim().length() < 3) { etProfileFullName.setError("at least 3 characters"); valid = false; } if (profileContactNumber.trim().isEmpty()) { etProfileContactNumber.setError("Empty"); valid = false; } else if (!profileContactNumber.isEmpty() && !PhoneNumberUtils.isGlobalPhoneNumber(profileContactNumber)) { etProfileContactNumber.setError("Number is invalid"); valid = false; } else { etProfileContactNumber.setError(null); } if (AppGlobals.getUserType() == 1) { if (profileDrivingExperience.trim().isEmpty()) { etProfileDrivingExperience.setError("Empty"); valid = false; } else { etProfileDrivingExperience.setError(null); } if (profileFullName.equals(AppGlobals.getPeronName()) && profileContactNumber.equals(AppGlobals.getPhoneNumber()) && profileDrivingExperience.equals(AppGlobals.getDrivingExperience()) && profileBio.equals(AppGlobals.getDriverBio()) && !imagePendingUpload) { Helpers.showSnackBar(getView(), "No changes to submit", Snackbar.LENGTH_LONG, "#ffffff"); valid = false; } } return valid; }
From source file:com.mifos.mifosxdroid.online.createnewclient.CreateNewClientFragment.java
@OnClick(R.id.btn_submit) public void onClickSubmitButton() { submissionDateString = tvSubmissionDate.getText().toString(); submissionDateString = DateHelper.getDateAsStringUsedForCollectionSheetPayload(submissionDateString) .replace("-", " "); dateOfBirthString = tvDateOfBirth.getText().toString(); dateOfBirthString = DateHelper.getDateAsStringUsedForDateofBirth(dateOfBirthString).replace("-", " "); ClientPayload clientPayload = new ClientPayload(); //Mandatory Fields clientPayload.setFirstname(etClientFirstName.getEditableText().toString()); clientPayload.setLastname(etClientLastName.getEditableText().toString()); clientPayload.setOfficeId(officeId); //Optional Fields, we do not need to add any check because these fields carry some // default values clientPayload.setActive(cbClientActiveStatus.isChecked()); clientPayload.setActivationDate(submissionDateString); clientPayload.setDateOfBirth(dateOfBirthString); //Optional Fields if (!TextUtils.isEmpty(etClientMiddleName.getEditableText().toString())) { clientPayload.setMiddlename(etClientMiddleName.getEditableText().toString()); }//from w ww . j av a 2 s.c o m if (PhoneNumberUtils.isGlobalPhoneNumber(etClientMobileNo.getEditableText().toString())) { clientPayload.setMobileNo(etClientMobileNo.getEditableText().toString()); } if (!TextUtils.isEmpty(etClientExternalId.getEditableText().toString())) { clientPayload.setExternalId(etClientExternalId.getEditableText().toString()); } if (!clientStaff.isEmpty()) { clientPayload.setStaffId(staffId); } if (!genderOptionsList.isEmpty()) { clientPayload.setGenderId(genderId); } if (!clientTypeList.isEmpty()) { clientPayload.setClientTypeId(clientTypeId); } if (!clientClassificationList.isEmpty()) { clientPayload.setClientClassificationId(clientClassificationId); } if (!isFirstNameValid()) { return; } if (!isMiddleNameValid()) { return; } if (isLastNameValid()) { if (hasDataTables) { DataTableListFragment fragment = DataTableListFragment.newInstance(clientsTemplate.getDataTables(), clientPayload, Constants.CREATE_CLIENT); FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager() .beginTransaction(); fragmentTransaction.addToBackStack(FragmentConstants.DATA_TABLE_LIST); fragmentTransaction.replace(R.id.container, fragment).commit(); } else { createNewClientPresenter.createClient(clientPayload); } } }
From source file:com.nbplus.hybrid.BasicWebViewClient.java
@JavascriptInterface public String getLineNumber() { Log.d(TAG, "getLineNumber() called"); String phoneNumberStr = PhoneState.getLineNumber1(mContext); Log.d(TAG, ">>> PhoneState.getLineNumber1 = " + phoneNumberStr); if (StringUtils.isEmptyString(phoneNumberStr)) { return null; }/*from www . ja v a2 s. c o m*/ if (PhoneNumberUtils.isGlobalPhoneNumber(phoneNumberStr)) { PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); Phonenumber.PhoneNumber phoneNumberProto; try { phoneNumberProto = phoneUtil.parse(phoneNumberStr, "KR"); return phoneUtil.format(phoneNumberProto, PhoneNumberUtil.PhoneNumberFormat.NATIONAL) .replace("-", "").replace(" ", "").replace("(", "").replace(")", ""); } catch (NumberParseException e) { Log.e(TAG, "NumberParseException was thrown: " + e.toString()); return phoneNumberStr; } } else { return phoneNumberStr; } }