public class

ContactUtil

extends Object
java.lang.Object
   ↳ com.gsma.services.rcs.contact.ContactUtil

Class Overview

Utility class for validation and unique formatting of phone numbers

Summary

Public Methods
ContactId formatContact(String contact)
Formats the given contact to uniquely represent a RCS contact phone number.
static ContactUtil getInstance(Context context)
Gets a singleton instance of ContactUtil.
String getMyCountryAreaCode()
Gets the user country area code.
String getMyCountryCode()
Gets the user country code.
Uri getVCard(Uri contactUri)
Returns the vCard of a contact.
boolean isMyCountryCodeDefined()
Checks if my country code is defined.
boolean isValidContact(String contact)
Checks the validity of a contact number.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public ContactId formatContact (String contact)

Since: API Level 1.5

Formats the given contact to uniquely represent a RCS contact phone number.

Parameters
contact the contact phone number to format.
Returns
  • the ContactId.
Throws
RcsPermissionDeniedException if the mobile country code failed to be read and is required to format the contact.

public static ContactUtil getInstance (Context context)

Since: API Level 1.5

Gets a singleton instance of ContactUtil.

Parameters
context the context.
Returns
  • the singleton instance.

public String getMyCountryAreaCode ()

Since: API Level 1.5

Gets the user country area code.

Returns
  • the country area code or null if it does not exist.
Throws
RcsPermissionDeniedException thrown if the mobile country code failed to be read.

public String getMyCountryCode ()

Since: API Level 1.5

Gets the user country code.

Returns
  • the user country code.
Throws
RcsPermissionDeniedException if the mobile country code failed to be read.

public Uri getVCard (Uri contactUri)

Since: API Level 1.5

Returns the vCard of a contact. The contact parameter contains the database URI of the contact in the address book. The method returns a Uri to the visit card. The visit card filename has the file extension .vcf and is generated from the address book vCard URI (see Android SDK attribute ContactsContract.Contacts.CONTENT_VCARD_URI which returns the referenced contact formatted as a vCard when opened through openAssetFileDescriptor(Uri, String)).

Parameters
contactUri Contact URI of the contact in the address book
Returns
  • Uri of vCard or null if not found

public boolean isMyCountryCodeDefined ()

Since: API Level 1.5

Checks if my country code is defined.

Returns
  • True if my country code is defined.

public boolean isValidContact (String contact)

Since: API Level 1.5

Checks the validity of a contact number.

Parameters
contact the contact number.
Returns
  • Returns true if the given contactId have the syntax of valid RCS contactId. If the string is too short (1 digit at least), too long (more than 15 digits) or contains illegal characters (valid characters are digits, space, '-', leading '+') then it returns false.
Throws
RcsPermissionDeniedException if the mobile country code failed to be read and is required to validate the contact.