Replies: 2 comments 1 reply
-
Hey @tinacious! Glad to hear that this library has helped you out 😁
AFAIK, there is no intent for picking multiple contacts. The only thing I see in the official docs is for picking a single contact, which is exactly what you are doing in the code snippet you provided.
As long as you are able to get Contact or RawContact ID(s), the you can use the APIs provided in this library to get all of the data you need. For example, if you have a list of Contact IDs, then getting all of the Contacts using this API would look like... val contactIds = listOf<Long>();
val contacts = Contacts(context)
.query()
.where { Contact.Id `in` contactIds }
.find() If you have a list of RawContact IDs and you want the list of Contacts... val rawContactIds = listOf<Long>();
val contacts = Contacts(context)
.query()
.where { RawContact.Id `in` rawContactIds }
.find() If instead you want to get RawContacts directly... val rawContactIds = listOf<Long>();
val rawContacts = Contacts(context)
.rawContactsQuery()
.where { RawContact.Id `in` rawContactIds }
.find()
Hmm.. I'm a little bit confused here. In order to use the APIs provided in this library, your app must explicitly request the In any case, your reasons are not my business so I won't stick my nose in it 😃 So, I'll focus on "would be possible to support a pick intent for multiple contacts". If Android itself does not provide a builtin intent to pick multiple contacts, then the app must implement an Activity to handle such an intent. There are several ways you can go about this.
I am hesitant to go with option 3 because the main purpose of this library is to provide CRUD APIs. I do have an experimental WIP Therefore, I suggest that you take option 2 (or option 1). LMK if that helped answer some of your questions 🙏 |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick reply! With regards to your comment:
I was able to use your library on a device that granted contacts permissions and it works great! For a device that doesn't grant contacts permissions, I didn't try to use your library since I wasn't able to pick multiple contacts from Android. Your idea to provide the contact IDs though seems like it would be a good next step if I were able to get a list of picked contacts (which doesn't seem possible right now, at least officially). I was hoping that I could use a pick intent and get the data from the provided content URI, similar to how you can pick an image without requesting access to a user's entire photo gallery. In the case of images, I always get the relevant data I need. I don't know if that is the case with contacts.
Happy to share again! I had mentioned I'd like to support users who are not comfortable sharing their contacts list:
I can, however, elaborate further – I fear users will see the contact permissions request and uninstall the app. I suspect there will be a significant amount of drop-off for security/privacy-focused users. I wanted to provide an alternate option where users can choose which contacts they're comfortable sharing instead of their entire address book, and at this time, sharing a contact one-by-one doesn't seem like a good user experience. Do you know if your library would be able to support getting first name, last name and phone number from a single picked contact from the code I provided in the initial message? Or is contacts permissions required to query the referenced data for columns in With regards to this:
I'm already doing that for users who have granted contacts permissions (with the help of your library). My main goal is to support an alternate experience for users who do not grant this permission and I was hoping to do so via Android pick intents (similar to how we can allow a user to pick a photo from any app on their phone that supports it without needing full photo gallery access).
This is not necessary and I agree with you entirely. And even if you were to do that, I don't think it would solve the problem since it likely requires elevated permissions to scan all the contacts to display them. Anyhow, hope that helps explain the reasons! Let me know if I can answer anything else! |
Beta Was this translation helpful? Give feedback.
-
First I'd like to say thank you for creating this amazing library. It's been a huge time-saver and has allowed me to get relevant fields for contacts quite easily without having to fumble with the
contentResolver
API's.I was wondering if it would be possible to support a pick intent for multiple contacts.
Reason: Many users do not feel comfortable giving full access to all their contacts.
Example UX:
Contacts(context).query().find()
, e.g.Query.Result
orList<Contact>
.This is some code I have for picking a single contact. It doesn't get the fields I need (that your library easily provides) like first name and last name, and it doesn't support multiple contacts, which makes the UX quite cumbersome:
Is it possible to:
Let me know if I can provide any additional information as I'd love to be able to support users who do not want to share their full contacts list.
Thank you! 🙏
Beta Was this translation helpful? Give feedback.
All reactions