Share via


ContactsContract.Intents.ActionVoiceSendMessageToContacts Field

Definition

Activity Action: Initiate a message to someone by voice.

[Android.Runtime.Register("ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS", ApiSince=24)]
public const string ActionVoiceSendMessageToContacts;
[<Android.Runtime.Register("ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS", ApiSince=24)>]
val mutable ActionVoiceSendMessageToContacts : string

Field Value

Attributes

Remarks

Activity Action: Initiate a message to someone by voice. The message could be text, audio, video or image(photo). This action supports messaging with a specific contact regardless of the underlying messaging protocol used.

The action could be originated from the Voice Assistant as a voice interaction. In such case, a receiving activity that supports android.content.Intent#CATEGORY_VOICE could check return value of android.app.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 android.content.Intent#CATEGORY_DEFAULT so it can be found by android.service.voice.VoiceInteractionSession#startVoiceActivity.

When the action was not initiated by Voice Assistant or when the receiving activity does not support android.content.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 RawContacts#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: <ul> <li>This activity should have a string meta-data field associated with it, #METADATA_ACCOUNT_TYPE, which defines RawContacts#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.</li> <li>This activity should have a string meta-data field associated with it, #METADATA_MIMETYPE, which defines DataColumns#MIMETYPE for your Contacts Provider implementation. For example, you can use "vnd.android.cursor.item/vnd.{$app_package_name}.profile" as MIME type.</li> <li>When filling Data table row for METADATA_MIMETYPE, column 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.</li> <li>Optionally, when filling Data table row for METADATA_MIMETYPE, column 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.</li> <li><em>Note: Do not use DATA3 to store the Contact Name. The Voice Assistant will already get the Contact Name from the RawContact’s display_name.</em></li> <li><em>Note: Some apps may choose to use phone number as the unique contact ID in DATA1. If this applies to you and you’d like phone number to be shown below the Contact Name by the Voice Assistant, then you may choose to leave DATA3 empty.</em></li> <li><em>Note: If your app also uses DATA3 to display contact details in the Contacts App, make sure it does not include prefix text such as "Message +<phone>" or "Free Message +<phone>", etc. If you must show the prefix text in the Contacts App, please use a different DATA# column, and update your contacts.xml to point to this new column. </em> </li> </ul> If the app chooses not to integrate with the Contacts Provider (in particular, when either METADATA_ACCOUNT_TYPE or METADATA_MIMETYPE field is missing), Voice Assistant will use existing phone number entries as contact ID's for such app.

Input: android.content.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 android.content.Intent#EXTRA_TEXT as a styled CharSequence. Otherwise, the message content will be supplied through android.content.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

Java documentation for android.provider.ContactsContract.Intents.ACTION_VOICE_SEND_MESSAGE_TO_CONTACTS.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to