Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#nestedclasses) \| [Constants](https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#constants) \| [Fields](https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#lfields) \| [Inherited Methods](https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#inhmethods)

# ContactsPickerSessionContract

*** ** * ** ***

` public final class ContactsPickerSessionContract `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.provider.ContactsPickerSessionContract |

<br />

*** ** * ** ***

<br />

The contract between the Contacts Picker session provider and client applications. This contract defines the intent actions, extras, and URI structure used to interact with the Contacts Picker to select contacts and retrieve their data.

It allows apps to select one or more contacts without requiring `https://developer.android.com/reference/android/Manifest.permission#READ_CONTACTS`, enhancing user privacy and security. The client app receives one-time access to the user-selected contacts data.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract.Session` Defines the contract for a Contacts Picker session, which represents the set of contacts selected by the user in a single picking operation. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#ACTION_PICK_CONTACTS` Intent action to launch the system Contacts Picker to select one or more contacts. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#AUTHORITY` The authority for the Contacts Picker session provider. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_MATCH_ALL_DATA_FIELDS` A boolean extra that, when set to `true`, instructs the system Contacts Picker to only display contacts that possess data fields corresponding to \*all\* MIME type specified in `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS`. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS` A `List<String>` extra that specifies the types of contact data the client application is requesting. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_SELECTION_LIMIT` An integer extra that defines the maximum number of contacts a user can select in a single session. |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/net/Uri` | `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#AUTHORITY_URI` The base `content://` style `https://developer.android.com/reference/android/net/Uri` for the Contacts Picker session provider. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### ACTION_PICK_CONTACTS

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String ACTION_PICK_CONTACTS
```

Intent action to launch the system Contacts Picker to select one or more contacts. This action provides a modern way for applications to obtain contact information, differing from `https://developer.android.com/reference/android/content/Intent#ACTION_PICK` and `https://developer.android.com/reference/android/content/Intent#ACTION_GET_CONTENT` in several key ways:

- It is specifically designed for picking contacts, offering a streamlined user experience.
- The calling application gains one-time read access to the user-selected contact data, without requiring `https://developer.android.com/reference/android/Manifest.permission#READ_CONTACTS`.
- Users benefit from a consistent UI to grant temporary access to their contact data.
- Client applications can specify and receive multiple data fields (MIME types) corresponding to the selected contacts.

To use this intent, create an `https://developer.android.com/reference/android/content/Intent` with this action and launch it using `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)`. The system Contacts Picker UI will be displayed, allowing the user to select one or more contacts. This contacts picker UI will:

- Have eligible contacts displayed as a scrollable list to the user.
- Enable users to select single/multiple contacts.
- Enable users to search for contacts using display name.

The display and selection behavior can be customized using the following extras:

- `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS`: (Required) Specifies the MIME types of contact data to be displayed in the picker and returned to the calling app. Contacts must have at least one of the specified MIME types, to be shown as available for selection.
- `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_MATCH_ALL_DATA_FIELDS`: (Optional) If set to `true`, only contacts possessing data for \*all\* MIME types specified in `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS` will be shown as available for selection. Defaults to `false`.
- `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_SELECTION_LIMIT`: (Optional) Defines the maximum number of contacts the user can select. Defaults to 50, with a maximum allowed value of 100.
- `https://developer.android.com/reference/android/content/Intent#EXTRA_ALLOW_MULTIPLE`: (Optional) If set to `true`, the user can select multiple contacts. The default behavior is single-select.

Upon successful contact(s) selection, the `https://developer.android.com/reference/android/app/Activity#onActivityResult(int,%20int,%20android.content.Intent)` callback will be invoked with `https://developer.android.com/reference/android/app/Activity#RESULT_OK`. The returned `https://developer.android.com/reference/android/content/Intent` will contain a session URI in its data field (see `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract.Session#CONTENT_URI`), which should be used to query the selected contact data. For example:

```
    Uri sessionUri = data.getData();
    Cursor cursor = getContentResolver().query(sessionUri, projection, null, null, null);
    // Process cursor data
```

Starting from Android 17, this intent is handled by a system application by default. Third-party applications should not handle this intent as they will be ignored when the system attempts to resolve it.

<br />

Constant Value: "android.provider.action.PICK_CONTACTS"

### AUTHORITY

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String AUTHORITY
```

The authority for the Contacts Picker session provider. This string is used to construct content URIs for interacting with the Contacts Picker session data.

<br />

Constant Value: "com.android.contacts.picker.sessions"

### EXTRA_PICK_CONTACTS_MATCH_ALL_DATA_FIELDS

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_PICK_CONTACTS_MATCH_ALL_DATA_FIELDS
```

A boolean extra that, when set to `true`, instructs the system Contacts Picker to only display contacts that possess data fields corresponding to \*all\* MIME type specified in `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS`.

If `false` (the default value), contacts will be displayed if they have data for \*at least one\* of the MIME types specified in `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS`.

<br />

Constant Value: "android.provider.extra.PICK_CONTACTS_MATCH_ALL_DATA_FIELDS"

### EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS
```

A `List<String>` extra that specifies the types of contact data the client application is requesting. This extra serves two primary purposes:

1. \*\*Filtering:\*\* Only contacts possessing data corresponding to at least one of the specified MIME types will be displayed in the Contacts Picker.
2. \*\*Data Return:\*\* For selected contacts, only data corresponding to these specified MIME types will be returned to the calling application.

This extra must be populated with one or more of the following MIME types:

- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredName#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Email#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredPostal#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Organization#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Relation#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Event#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Photo#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.GroupMembership#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Website#CONTENT_ITEM_TYPE`
- `https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Nickname#CONTENT_ITEM_TYPE`

If `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#EXTRA_PICK_CONTACTS_MATCH_ALL_DATA_FIELDS` is set to `true`, only contacts having data corresponding to \*all\* of the MIME types specified in this extra will be displayed.

The Contacts Picker will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException` if any of the MIME types provided in this extra are not among the allowed types listed above.

Clients are required to set this extra to ensure the picker can determine which information should be made available for selection. Example usage:

```
    List<String> requestedMimeTypes = new ArrayList<>();
    requestedMimeTypes.add(ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE);
    requestedMimeTypes.add(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
    intent.putStringArrayListExtra(
            ContactsPickerSessionContract.EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS,
            (ArrayList<String>) requestedMimeTypes);
```

<br />

<br />

Constant Value: "android.provider.extra.PICK_CONTACTS_REQUESTED_DATA_FIELDS"

### EXTRA_PICK_CONTACTS_SELECTION_LIMIT

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_PICK_CONTACTS_SELECTION_LIMIT
```

An integer extra that defines the maximum number of contacts a user can select in a single session. The Contacts Picker uses this value to configure its UI.

If this extra is not set, the default selection limit is 50. The absolute maximum allowed value is 100.

Clients should not set this value higher than the documented maximum limit. The application handling `https://developer.android.com/reference/android/provider/ContactsPickerSessionContract#ACTION_PICK_CONTACTS` will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException` if the provided value exceeds the maximum allowed limit.

<br />

Constant Value: "android.provider.extra.PICK_CONTACTS_SELECTION_LIMIT"

## Fields

### AUTHORITY_URI

Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Uri AUTHORITY_URI
```

The base `content://` style `https://developer.android.com/reference/android/net/Uri` for the Contacts Picker session provider. All session-specific URIs are built upon this base URI.

<br />