public static final class ContactsContract.Intents extends Object
Intents
that involve contacts.Modifier and Type | Class and Description |
---|---|
static class |
ContactsContract.Intents.Insert
Convenience class that contains string constants used
to create contact
Intents . |
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_GET_MULTIPLE_PHONES
Starts an Activity that lets the user select the multiple phones from a
list of phone numbers which come from the contacts or
EXTRA_PHONE_URIS . |
static String |
ACTION_PROFILE_CHANGED
A broadcast action which is sent when any change has been made to the profile, such
as the profile name or the picture.
|
static String |
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
Activity Action: Initiate a message to someone by voice.
|
static String |
ATTACH_IMAGE
Starts an Activity that lets the user pick a contact to attach an image to.
|
static String |
CONTACTS_DATABASE_CREATED
This is the intent that is fired when the contacts database is created.
|
static String |
EXTRA_CREATE_DESCRIPTION
Used with
SHOW_OR_CREATE_CONTACT to specify an exact
description to be shown when prompting user about creating a new
contact. |
static String |
EXTRA_EXCLUDE_MIMES
Deprecated.
|
static String |
EXTRA_FORCE_CREATE
Used with
SHOW_OR_CREATE_CONTACT to force creating a new
contact if no matching contact found. |
static String |
EXTRA_MODE
Deprecated.
|
static String |
EXTRA_PHONE_URIS
Used with
ACTION_GET_MULTIPLE_PHONES as the input or output value. |
static String |
EXTRA_RECIPIENT_CONTACT_CHAT_ID
This extra specifies a messaging app’s unique ID(s) for the contact(s), used with
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS to supply the recipient(s). |
static String |
EXTRA_RECIPIENT_CONTACT_NAME
This extra specifies the contact name (full name from the Contacts Provider), used with
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS to supply the recipient. |
static String |
EXTRA_RECIPIENT_CONTACT_URI
This extra specifies a content provider uri(s) for the contact(s) (if the contacts were
located in the Contacts Provider), used with
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS to supply the recipient(s). |
static String |
EXTRA_TARGET_RECT
Deprecated.
|
static String |
INVITE_CONTACT
This is the intent that is fired when the user clicks the "invite to the network" button
on a contact.
|
static String |
METADATA_ACCOUNT_TYPE
A string associated with an
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS activity
describing ContactsContract.SyncColumns.ACCOUNT_TYPE for the corresponding Contacts Provider
implementation. |
static String |
METADATA_MIMETYPE
A string associated with an
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS activity
describing ContactsContract.DataColumns.MIMETYPE for the corresponding Contacts Provider
implementation. |
static int |
MODE_LARGE
Deprecated.
|
static int |
MODE_MEDIUM
Deprecated.
|
static int |
MODE_SMALL
Deprecated.
|
static String |
SEARCH_SUGGESTION_CLICKED
This is the intent that is fired when a search suggestion is clicked on.
|
static String |
SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED
This is the intent that is fired when a search suggestion for creating a contact
is clicked on.
|
static String |
SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED
This is the intent that is fired when a search suggestion for dialing a number
is clicked on.
|
static String |
SHOW_OR_CREATE_CONTACT
Takes as input a data URI with a mailto: or tel: scheme.
|
Constructor and Description |
---|
Intents() |
public static final String SEARCH_SUGGESTION_CLICKED
public static final String SEARCH_SUGGESTION_DIAL_NUMBER_CLICKED
public static final String SEARCH_SUGGESTION_CREATE_CONTACT_CLICKED
public static final String CONTACTS_DATABASE_CREATED
The READ_CONTACT permission is required to receive these broadcasts.
public static final String ATTACH_IMAGE
public static final String INVITE_CONTACT
Intent.getData()
contains the lookup URI for the contact.
public static final String SHOW_OR_CREATE_CONTACT
For mailto:
URIs, the scheme specific portion must be a
raw email address, such as one built using
Uri.fromParts(String, String, String)
.
For tel:
URIs, the scheme specific portion is compared
to existing numbers using the standard caller ID lookup algorithm.
The number must be properly encoded, for example using
Uri.fromParts(String, String, String)
.
Any extras from the ContactsContract.Intents.Insert
class will be passed along to the
create activity if there are no contacts to show.
Passing true for the EXTRA_FORCE_CREATE
extra will skip
prompting the user when the contact doesn't exist.
public static final String ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
The action could be originated from the Voice Assistant as a voice interaction. In such
case, a receiving activity that supports Intent.CATEGORY_VOICE
could check return value of Activity.isVoiceInteractionRoot()
before
proceeding. By doing this check the activity verifies that the action indeed was
initiated by Voice Assistant and could send a message right away, without any further
input from the user. This allows for a smooth user experience when sending a message by
voice. Note: this activity must also support the Intent.CATEGORY_DEFAULT
so it can be found by VoiceInteractionSession.startVoiceActivity(android.content.Intent)
.
When the action was not initiated by Voice Assistant or when the receiving activity does
not support Intent.CATEGORY_VOICE
, the activity must confirm
with the user before sending the message (because in this case it is unknown which app
sent the intent, it could be malicious).
To allow the Voice Assistant to help users with contacts disambiguation, the messaging
app may choose to integrate with the Contacts Provider. You will need to specify a new
MIME type in order to store your app’s unique contact IDs and optional human readable
labels in the Data table. The Voice Assistant needs to know this MIME type and ContactsContract.SyncColumns.ACCOUNT_TYPE
that you are using in order to provide the smooth contact
disambiguation user experience. The following convention should be met when performing
such integration:
METADATA_ACCOUNT_TYPE
, which defines ContactsContract.SyncColumns.ACCOUNT_TYPE
for your Contacts
Provider implementation. The account type should be globally unique, for example you can
use your app package name as the account type.METADATA_MIMETYPE
, which defines ContactsContract.DataColumns.MIMETYPE
for your Contacts
Provider implementation. For example, you can use
"vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.ContactsContract.DataColumns.DATA1
should store the unique contact ID as understood by the app. This value will be used in
the EXTRA_RECIPIENT_CONTACT_CHAT_ID
.ContactsContract.DataColumns.DATA3
could store a human readable label for the ID. For example it could be
phone number or human readable username/user_id like "a_super_cool_user_name". This label
may be shown below the Contact Name by the Voice Assistant as the user completes the
voice action. If DATA3 is empty, the ID in DATA1 may be shown instead.ContactsContract.ContactOptionsColumns.TIMES_CONTACTED
entry through DataUsageFeedback class.
Doing this will allow Voice Assistant to bias speech recognition to contacts frequently
contacted, this is particularly useful for contact names that are hard to pronounce.
Input: Intent.getType()
is the MIME type of the data being sent.
The intent sender will always put the concrete mime type in the intent type, like
"text/plain" or "audio/wav" for example. If the MIME type is "text/plain", message to
sent will be provided via Intent.EXTRA_TEXT
as a styled
CharSequence. Otherwise, the message content will be supplied through Intent.setClipData(ClipData)
as a content provider URI(s). In the latter
case, EXTRA_TEXT could still be supplied optionally; for example, for audio messages
ClipData will contain URI of a recording and EXTRA_TEXT could contain the text
transcription of this recording.
The message can have n recipients. The n-th recipient of the message will be provided as
n-th elements of EXTRA_RECIPIENT_CONTACT_URI
, EXTRA_RECIPIENT_CONTACT_CHAT_ID
and EXTRA_RECIPIENT_CONTACT_NAME
(as a
consequence, EXTRA_RECIPIENT_CONTACT_URI, EXTRA_RECIPIENT_CONTACT_CHAT_ID and
EXTRA_RECIPIENT_CONTACT_NAME should all be of length n). If neither of these 3 elements
is provided (e.g. all 3 are null) for the recipient or if the information provided is
ambiguous then the activity should prompt the user for the recipient to send the message
to.
Output: nothing
public static final String EXTRA_RECIPIENT_CONTACT_URI
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
to supply the recipient(s). The value of this
extra is a String[]
. The number of elements in the array should be equal to
number of recipients (and consistent with EXTRA_RECIPIENT_CONTACT_CHAT_ID
and
EXTRA_RECIPIENT_CONTACT_NAME
). When the value of the element for the particular
recipient is absent, it will be set to null.
Note: one contact may have multiple accounts (e.g. Chat IDs) on a specific messaging accounts on the same messaging app.
Example value: {"content://com.android.contacts/contacts/16"}
public static final String EXTRA_RECIPIENT_CONTACT_CHAT_ID
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
to supply the recipient(s). The value of this
extra is a String[]
. The number of elements in the array should be equal to
number of recipients (and consistent with EXTRA_RECIPIENT_CONTACT_URI
and EXTRA_RECIPIENT_CONTACT_NAME
). When the value of the element for the particular
recipient is absent, it will be set to null.
The value of the elements comes from the ContactsContract.DataColumns.DATA1
column in Contacts
Provider with ContactsContract.DataColumns.MIMETYPE
from METADATA_MIMETYPE
(if both
METADATA_ACCOUNT_TYPE
and METADATA_MIMETYPE
are specified by the app;
otherwise, the value will be a phone number), and should be the unambiguous contact
endpoint. This value is app-specific, it could be some proprietary ID or a phone number.
public static final String EXTRA_RECIPIENT_CONTACT_NAME
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
to supply the recipient. The value of this
extra is a String[]
. The number of elements in the array should be equal to
number of recipients (and consistent with EXTRA_RECIPIENT_CONTACT_URI
and EXTRA_RECIPIENT_CONTACT_CHAT_ID
). When the value of the element for the particular
recipient is absent, it will be set to null.
The value of the elements comes from RawContact's display_name column.
Example value: {"Jane Doe"}
public static final String METADATA_ACCOUNT_TYPE
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
activity
describing ContactsContract.SyncColumns.ACCOUNT_TYPE
for the corresponding Contacts Provider
implementation.public static final String METADATA_MIMETYPE
ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS
activity
describing ContactsContract.DataColumns.MIMETYPE
for the corresponding Contacts Provider
implementation.public static final String ACTION_GET_MULTIPLE_PHONES
EXTRA_PHONE_URIS
.
The phone numbers being passed in through EXTRA_PHONE_URIS
could belong to the contacts or not, and will be selected by default.
The user's selection will be returned from
Activity.onActivityResult(int, int, android.content.Intent)
if the resultCode is
Activity.RESULT_OK
, the array of picked phone
numbers are in the Intent's
EXTRA_PHONE_URIS
; otherwise, the
Activity.RESULT_CANCELED
is returned if the user
left the Activity without changing the selection.
public static final String ACTION_PROFILE_CHANGED
public static final String EXTRA_FORCE_CREATE
SHOW_OR_CREATE_CONTACT
to force creating a new
contact if no matching contact found. Otherwise, default behavior is
to prompt user with dialog before creating.
Type: BOOLEAN
public static final String EXTRA_CREATE_DESCRIPTION
SHOW_OR_CREATE_CONTACT
to specify an exact
description to be shown when prompting user about creating a new
contact.
Type: STRING
public static final String EXTRA_PHONE_URIS
ACTION_GET_MULTIPLE_PHONES
as the input or output value.
The phone numbers want to be picked by default should be passed in as input value. These phone numbers could belong to the contacts or not.
The phone numbers which were picked by the user are returned as output value.
Type: array of URIs, the tel URI is used for the phone numbers which don't belong to any contact, the content URI is used for phone id in contacts.
@Deprecated public static final String EXTRA_TARGET_RECT
SHOW_OR_CREATE_CONTACT
to specify a
dialog location using screen coordinates. When not specified, the
dialog will be centered.@Deprecated public static final String EXTRA_MODE
SHOW_OR_CREATE_CONTACT
to specify a
desired dialog style, usually a variation on size. One of
MODE_SMALL
, MODE_MEDIUM
, or MODE_LARGE
.@Deprecated public static final int MODE_SMALL
EXTRA_MODE
to show a small-sized dialog.@Deprecated public static final int MODE_MEDIUM
EXTRA_MODE
to show a medium-sized dialog.@Deprecated public static final int MODE_LARGE
EXTRA_MODE
to show a large-sized dialog.@Deprecated public static final String EXTRA_EXCLUDE_MIMES
SHOW_OR_CREATE_CONTACT
to indicate
a list of specific MIME-types to exclude and not display. Stored as a
String
array.