當前位置: 首頁>>代碼示例>>Java>>正文


Java PhoneNumberUtils.isWellFormedSmsAddress方法代碼示例

本文整理匯總了Java中android.telephony.PhoneNumberUtils.isWellFormedSmsAddress方法的典型用法代碼示例。如果您正苦於以下問題:Java PhoneNumberUtils.isWellFormedSmsAddress方法的具體用法?Java PhoneNumberUtils.isWellFormedSmsAddress怎麽用?Java PhoneNumberUtils.isWellFormedSmsAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.PhoneNumberUtils的用法示例。


在下文中一共展示了PhoneNumberUtils.isWellFormedSmsAddress方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isValidAddress

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
private boolean isValidAddress(String number, boolean isMms) {
    /*if (isMms) {
        return MessageUtils.isValidMmsAddress(number);
    } else {*/
        // TODO: PhoneNumberUtils.isWellFormedSmsAddress() only check if the number is a valid
        // GSM SMS address. If the address contains a dialable char, it considers it a well
        // formed SMS addr. CDMA doesn't work that way and has a different parser for SMS
        // address (see CdmaSmsAddress.parse(String address)). We should definitely fix this!!!
    return PhoneNumberUtils.isWellFormedSmsAddress(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:11,代碼來源:RecipientsEditor.java

示例2: isNumberAddress

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
@VisibleForTesting
static boolean isNumberAddress(@NonNull String number) {
  if (number.contains("@"))             return false;
  if (GroupUtil.isEncodedGroup(number)) return false;

  final String networkNumber = PhoneNumberUtils.extractNetworkPortion(number);

  if (TextUtils.isEmpty(networkNumber)) return false;
  if (networkNumber.length() < 3)       return false;

  return PhoneNumberUtils.isWellFormedSmsAddress(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:13,代碼來源:CanonicalAddressDatabase.java

示例3: parseBracketedNumber

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
private static String parseBracketedNumber(String recipient) throws RecipientFormattingException {
  int begin    = recipient.indexOf('<');
  int end      = recipient.indexOf('>');
  String value = recipient.substring(begin + 1, end);

  if (PhoneNumberUtils.isWellFormedSmsAddress(value))
    return value;
  else
    throw new RecipientFormattingException("Bracketed value: " + value + " is not valid.");
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:11,代碼來源:RecipientsFormatter.java

示例4: parseRecipient

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
private static String parseRecipient(String recipient) throws RecipientFormattingException {
  recipient = recipient.trim();

  if ((recipient.indexOf('<') != -1) && (recipient.indexOf('>') != -1))
    return parseBracketedNumber(recipient);

  if (PhoneNumberUtils.isWellFormedSmsAddress(recipient))
    return recipient;

  throw new RecipientFormattingException("Recipient: " + recipient + " is badly formatted.");
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:12,代碼來源:RecipientsFormatter.java

示例5: isNumberAddress

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
@VisibleForTesting
static boolean isNumberAddress(String number) {
  if (number.contains("@"))
    return false;
  if (GroupUtil.isEncodedGroup(number))
    return false;

  final String networkNumber = PhoneNumberUtils.extractNetworkPortion(number);
  if (TextUtils.isEmpty(networkNumber))
    return false;
  if (networkNumber.length() < 3)
    return false;

  return PhoneNumberUtils.isWellFormedSmsAddress(number);
}
 
開發者ID:redcracker,項目名稱:TextSecure,代碼行數:16,代碼來源:CanonicalAddressDatabase.java

示例6: isValid

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
@SuppressWarnings({"SimplifiableIfStatement", "RedundantIfStatement"})
@Override
public boolean isValid() {
    if (Utils.isBlank(sms.destination))
        return false;
    if (!PhoneNumberUtils.isWellFormedSmsAddress(sms.destination))
        return false;
    if (Utils.isBlank(sms.content))
        return false;
    return true;
}
 
開發者ID:renyuneyun,項目名稱:Easer,代碼行數:12,代碼來源:SmsOperationData.java

示例7: getCursorForRecipientFilter

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
/***
 * If the code below looks shitty to you, that's because it was taken
 * directly from the Android source, where shitty code is all you get.
 */

public Cursor getCursorForRecipientFilter(CharSequence constraint,
    ContentResolver mContentResolver)
{
  final String SORT_ORDER = Contacts.TIMES_CONTACTED + " DESC," +
                            Contacts.DISPLAY_NAME + "," +
                            Contacts.Data.IS_SUPER_PRIMARY + " DESC," +
                            Phone.TYPE;

  final String[] PROJECTION_PHONE = {
      Phone._ID,                  // 0
      Phone.CONTACT_ID,           // 1
      Phone.TYPE,                 // 2
      Phone.NUMBER,               // 3
      Phone.LABEL,                // 4
      Phone.DISPLAY_NAME,         // 5
  };

  String phone = "";
  String cons  = null;

  if (constraint != null) {
    cons = constraint.toString();

    if (RecipientsAdapter.usefulAsDigits(cons)) {
      phone = PhoneNumberUtils.convertKeypadLettersToDigits(cons);
      if (phone.equals(cons) && !PhoneNumberUtils.isWellFormedSmsAddress(phone)) {
        phone = "";
      } else {
        phone = phone.trim();
      }
    }
  }
  Uri uri = Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(cons));
  String selection = String.format("%s=%s OR %s=%s OR %s=%s",
                                   Phone.TYPE,
                                   Phone.TYPE_MOBILE,
                                   Phone.TYPE,
                                   Phone.TYPE_WORK_MOBILE,
                                   Phone.TYPE,
                                   Phone.TYPE_MMS);

  Cursor phoneCursor = mContentResolver.query(uri,
                                              PROJECTION_PHONE,
                                              null,
                                              null,
                                              SORT_ORDER);

  if (phone.length() > 0) {
    ArrayList result = new ArrayList();
    result.add(Integer.valueOf(-1));                    // ID
    result.add(Long.valueOf(-1));                       // CONTACT_ID
    result.add(Integer.valueOf(Phone.TYPE_CUSTOM));     // TYPE
    result.add(phone);                                  // NUMBER

  /*
  * The "\u00A0" keeps Phone.getDisplayLabel() from deciding
  * to display the default label ("Home") next to the transformation
  * of the letters into numbers.
  */
    result.add("\u00A0");                               // LABEL
    result.add(cons);                                   // NAME

    ArrayList<ArrayList> wrap = new ArrayList<ArrayList>();
    wrap.add(result);

    ArrayListCursor translated = new ArrayListCursor(PROJECTION_PHONE, wrap);

    return new MergeCursor(new Cursor[] { translated, phoneCursor });
  } else {
    return phoneCursor;
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:78,代碼來源:ContactAccessor.java

示例8: isValidSmsOrEmail

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
public static boolean isValidSmsOrEmail(String number) {
  return PhoneNumberUtils.isWellFormedSmsAddress(number) || isValidEmail(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:4,代碼來源:NumberUtil.java

示例9: isValidSmsOrEmailOrGroup

import android.telephony.PhoneNumberUtils; //導入方法依賴的package包/類
public static boolean isValidSmsOrEmailOrGroup(String number) {
  return PhoneNumberUtils.isWellFormedSmsAddress(number) ||
      isValidEmail(number) ||
      GroupUtil.isEncodedGroup(number);
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:6,代碼來源:NumberUtil.java


注:本文中的android.telephony.PhoneNumberUtils.isWellFormedSmsAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。