PhoneLookup
class PhoneLookup : BaseColumns, ContactsContract.PhoneLookupColumns, ContactsContract.ContactsColumns, ContactsContract.ContactOptionsColumns, ContactsContract.ContactNameColumns
A table that represents the result of looking up a phone number, for example for caller ID. To perform a lookup you must append the number you want to find to CONTENT_FILTER_URI
. This query is highly optimized.
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME,...
Columns
Columns from the Contacts table are also available through a join.
Summary
Constants |
static String |
If this boolean parameter is set to true, then the appended query is treated as a SIP address and the lookup will be performed against SIP addresses in the user's contacts.
|
Inherited constants |
|
From class ContactsColumns
String |
CONTACT_LAST_UPDATED_TIMESTAMP
Timestamp (milliseconds since epoch) of when this contact was last updated. This includes updates to all data associated with this contact including raw contacts. Any modification (including deletes and inserts) of underlying contact data are also reflected in this timestamp.
|
String |
DISPLAY_NAME
The display name for the contact.
Type: TEXT
|
String |
HAS_PHONE_NUMBER
An indicator of whether this contact has at least one phone number. "1" if there is at least one phone number, "0" otherwise.
Type: INTEGER
|
String |
IN_DEFAULT_DIRECTORY
Flag that reflects whether the contact exists inside the default directory. Ie, whether the contact is designed to only be visible outside search.
|
String |
IN_VISIBLE_GROUP
Flag that reflects the Groups#GROUP_VISIBLE state of any CommonDataKinds.GroupMembership for this contact.
|
String |
IS_USER_PROFILE
Flag that reflects whether this contact represents the user's personal profile entry.
|
String |
LOOKUP_KEY
An opaque value that contains hints on how to find the contact if its row id changed as a result of a sync or aggregation.
|
String |
NAME_RAW_CONTACT_ID
Reference to the row in the RawContacts table holding the contact name.
Type: INTEGER REFERENCES raw_contacts(_id)
|
String |
PHOTO_FILE_ID
Photo file ID of the full-size photo. If present, this will be used to populate PHOTO_URI . The ID can also be used with ContactsContract.DisplayPhoto#CONTENT_URI to create a URI to the photo. If this is present, PHOTO_ID is also guaranteed to be populated.
Type: INTEGER
|
String |
PHOTO_ID
Reference to the row in the data table holding the photo. A photo can be referred to either by ID (this field) or by URI (see PHOTO_THUMBNAIL_URI and PHOTO_URI ). If PHOTO_ID is null, consult PHOTO_URI or PHOTO_THUMBNAIL_URI , which is a more generic mechanism for referencing the contact photo, especially for contacts returned by non-local directories (see Directory ).
Type: INTEGER REFERENCES data(_id)
|
String |
PHOTO_THUMBNAIL_URI
A URI that can be used to retrieve a thumbnail of the contact's photo. A photo can be referred to either by a URI (this field or PHOTO_URI ) or by ID (see PHOTO_ID ). If PHOTO_ID is not null, PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). If the content provider does not differentiate between full-size photos and thumbnail photos, PHOTO_THUMBNAIL_URI and PHOTO_URI can contain the same value, but either both shall be null or both not null.
Type: TEXT
|
String |
PHOTO_URI
A URI that can be used to retrieve the contact's full-size photo. If PHOTO_FILE_ID is not null, this will be populated with a URI based off ContactsContract.DisplayPhoto#CONTENT_URI . Otherwise, this will be populated with the same value as PHOTO_THUMBNAIL_URI . A photo can be referred to either by a URI (this field) or by ID (see PHOTO_ID ). If either PHOTO_FILE_ID or PHOTO_ID is not null, PHOTO_URI and PHOTO_THUMBNAIL_URI shall not be null (but not necessarily vice versa). Thus using PHOTO_URI is a more robust method of retrieving contact photos.
Type: TEXT
|
|
From class ContactOptionsColumns
String |
CUSTOM_RINGTONE
URI for a custom ringtone associated with the contact. If null or missing, the default ringtone is used.
Type: TEXT (URI to the ringtone)
|
String |
LAST_TIME_CONTACTED
The last time a contact was contacted.
Caution: If you publish your app to the Google Play Store, this field is obsolete, regardless of Android version. For more information, see the Contacts Provider page.
Type: INTEGER
|
String |
PINNED
The position at which the contact is pinned. If PinnedPositions#UNPINNED , the contact is not pinned. Also see PinnedPositions .
Type: INTEGER
|
String |
SEND_TO_VOICEMAIL
Whether the contact should always be sent to voicemail. If missing, defaults to false.
Type: INTEGER (0 for false, 1 for true)
|
String |
STARRED
Is the contact starred?
Type: INTEGER (boolean)
|
String |
TIMES_CONTACTED
The number of times a contact has been contacted.
Caution: If you publish your app to the Google Play Store, this field is obsolete, regardless of Android version. For more information, see the Contacts Provider page.
Type: INTEGER
|
|
From class ContactNameColumns
String |
DISPLAY_NAME_ALTERNATIVE
An alternative representation of the display name, such as "family name first" instead of "given name first" for Western names. If an alternative is not available, the values should be the same as DISPLAY_NAME_PRIMARY .
A contacts provider is free to provide alternatives as necessary for its target market. For example the default Android Open Source Project contacts provider currently provides an alternative in a single case: if the display name is based on the structured name and the structured name follows the Western full name style, then the field contains the "family name first" version of the full name. Other cases may be added later.
|
String |
DISPLAY_NAME_PRIMARY
The standard text shown as the contact's display name, based on the best available information for the contact (for example, it might be the email address if the name is not available). The information actually used to compute the name is stored in DISPLAY_NAME_SOURCE .
A contacts provider is free to choose whatever representation makes most sense for its target market. For example in the default Android Open Source Project implementation, if the display name is based on the structured name and the structured name follows the Western full-name style, then this field contains the "given name first" version of the full name.
|
String |
DISPLAY_NAME_SOURCE
The kind of data that is used as the display name for the contact, such as structured name or email address. See DisplayNameSources .
|
String |
PHONETIC_NAME
Pronunciation of the full name in the phonetic alphabet specified by PHONETIC_NAME_STYLE .
The value may be set manually by the user. This capability is of interest only in countries with commonly used phonetic alphabets, such as Japan and Korea. See PhoneticNameStyle .
|
String |
PHONETIC_NAME_STYLE
The phonetic alphabet used to represent the PHONETIC_NAME . See PhoneticNameStyle .
|
String |
SORT_KEY_ALTERNATIVE
Sort key based on the alternative representation of the full name, DISPLAY_NAME_ALTERNATIVE . Thus for Western names, it is the one using the "family name first" format.
|
String |
SORT_KEY_PRIMARY
Sort key that takes into account locale-based traditions for sorting names in address books. The default sort key is DISPLAY_NAME_PRIMARY . For Chinese names the sort key is the name's Pinyin spelling, and for Japanese names it is the Hiragana version of the phonetic name.
|
|
|
Properties |
static Uri! |
The content:// style URI for this table.
|
static Uri! |
URI used for looking up contacts by phone number on the contact databases of both the calling user and the managed profile that is linked to it.
|
Constants
QUERY_PARAMETER_SIP_ADDRESS
static val QUERY_PARAMETER_SIP_ADDRESS: String
If this boolean parameter is set to true, then the appended query is treated as a SIP address and the lookup will be performed against SIP addresses in the user's contacts.
Value: "sip"
Properties
CONTENT_FILTER_URI
static val CONTENT_FILTER_URI: Uri!
The content:// style URI for this table.
Caution: If you publish your app to the Google Play Store, this field doesn't sort results based on contacts frequency. For more information, see the Contacts Provider page. Append the phone number you want to lookup to this URI and query it to perform a lookup. For example:
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(phoneNumber));
ENTERPRISE_CONTENT_FILTER_URI
static val ENTERPRISE_CONTENT_FILTER_URI: Uri!
URI used for looking up contacts by phone number on the contact databases of both the calling user and the managed profile that is linked to it.
It supports the same semantics as CONTENT_FILTER_URI
and returns the same columns.
If the device has no managed profile that is linked to the calling user, it behaves in the exact same way as CONTENT_FILTER_URI
.
If there is a managed profile linked to the calling user, it first queries the calling user's contact database, and only if no matching contacts are found there it then queries the managed profile database.
Caution: If you publish your app to the Google Play Store, this field doesn't sort results based on contacts frequency. For more information, see the Contacts Provider page.
If a result is from the managed profile, the following changes are made to the data:
PHOTO_THUMBNAIL_URI
and PHOTO_URI
will be rewritten to special URIs. Use android.content.ContentResolver#openAssetFileDescriptor or its siblings to load pictures from them.
PHOTO_ID
and PHOTO_FILE_ID
will be set to null. Don't use them.
CONTACT_ID
and LOOKUP_KEY
will be replaced with artificial values. These values will be consistent across multiple queries, but do not use them in places that do not explicitly say they accept them. If they are used in the selection
param in android.content.ContentProvider#query, the result is undefined.
- In order to tell whether a contact is from the managed profile, use
ContactsContract.Contacts#isEnterpriseContactId(long)
.
A contact lookup URL built by ContactsContract.Contacts#getLookupUri(long, String)
with a CONTACT_ID
and a LOOKUP_KEY
returned by this API can be passed to android.provider.ContactsContract.QuickContact#showQuickContact even if a contact is from the managed profile.
Uri lookupUri = Uri.withAppendedPath(PhoneLookup.ENTERPRISE_CONTENT_FILTER_URI,
Uri.encode(phoneNumber));