Compose Message "To" field allows adding sequence of characters as contact

When we select this option, this sequence of characters (which is neither a
valid email address nor a phone number), gets stored in contact with type MOBILE.

Fix: In function canAddToContacts, adding a check to validate whether the contact
to be added is a valid email address or phone number. If not, user will not be shown
with the option "Add to Contacts".
This commit is contained in:
Satish Roddom
2009-08-21 02:51:39 -05:00
committed by Wink Saville
parent 4e9718d6ae
commit e43a6a02dd

View File

@@ -1263,6 +1263,21 @@ public final class Telephony {
return match.matches();
}
/**
* Returns true if the number is a Phone number
*
* @param number the input number to be tested
* @return true if number is a Phone number
*/
public static boolean isPhoneNumber(String number) {
if (TextUtils.isEmpty(number)) {
return false;
}
Matcher match = Regex.PHONE_PATTERN.matcher(number);
return match.matches();
}
/**
* Contains all MMS messages in the MMS app's inbox.
*/