From c3d6e10cae470ad2a9d97069dd4fda949c25a05f Mon Sep 17 00:00:00 2001 From: Yacine Rezgui Date: Mon, 18 May 2026 16:56:53 +0200 Subject: [PATCH] Enable system contact picker in ContactPickerActivity --- .../main/java/com/example/contacts/ContactPickerActivity.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contacts/src/main/java/com/example/contacts/ContactPickerActivity.kt b/contacts/src/main/java/com/example/contacts/ContactPickerActivity.kt index 50487d58d..cfab760a8 100644 --- a/contacts/src/main/java/com/example/contacts/ContactPickerActivity.kt +++ b/contacts/src/main/java/com/example/contacts/ContactPickerActivity.kt @@ -20,6 +20,7 @@ import android.app.Activity import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent +import android.content.Intent.EXTRA_USE_SYSTEM_CONTACTS_PICKER import android.net.Uri import android.os.Bundle import android.provider.ContactsContract @@ -117,6 +118,7 @@ fun ContactPickerScreen(modifier: Modifier) { // Set up the intent for the Contact Picker val pickContactIntent = Intent(ACTION_PICK_CONTACTS).apply { + putExtra(EXTRA_USE_SYSTEM_CONTACTS_PICKER, true) putStringArrayListExtra( EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS, requestedFields @@ -144,6 +146,7 @@ fun ContactPickerScreen(modifier: Modifier) { // Set up the intent for the Contact Picker val pickContactIntent = Intent(ACTION_PICK_CONTACTS).apply { + putExtra(EXTRA_USE_SYSTEM_CONTACTS_PICKER, true) // Enable multi-select putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) // Set limit of selectable contacts @@ -177,6 +180,7 @@ fun ContactPickerScreen(modifier: Modifier) { // of specific items (like a specific phone number or email) separately, // rather than selecting the whole contact. val pickContactIntent = Intent(ACTION_PICK_CONTACTS).apply { + putExtra(EXTRA_USE_SYSTEM_CONTACTS_PICKER, true) putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) putStringArrayListExtra( EXTRA_PICK_CONTACTS_REQUESTED_DATA_FIELDS, @@ -281,4 +285,4 @@ private suspend fun processContactPickerResultUri( return@withContext contactsMap.values.toList() } -// [END android_contact_picker_result_uri_processing] \ No newline at end of file +// [END android_contact_picker_result_uri_processing]