tamir7 / contacts Goto Github PK
View Code? Open in Web Editor NEWAndroid Contacts API
Android Contacts API
List contactList = Contacts.getQuery().find();
I am getting random sequence for phone number when particular contact has multiple phone number.
I want it in the same order as we have stored on that contact, the sequence should not be changed.
Example :
Contact name : Mitesh Machhoya
Type : Mobile ---> 54682 58795
Type : Mobile ---> 24586 97412
Type : Home ---> 35648 71454
etc...
when I retrieve the list of numbers from "Mitesh Machhoya" contact, its giving random sequence of the phone numbers
can anyone help me?
This will help to get the contacts which are STARRED or marked as FAVOURITES.
Hi,
Thanks for this lib!
It is possible to get a contact by the CONTACT_ID ?
Sorry for my bad English but I have problems with your library and need your help.
1 : When I add new contact or new number in my contacts, this API did not return correct results I desired. Which takes a while to display the correct new results.
2 : Some contact without number did not show even though I did not set "hasPhoneNumber()".
Thanks.
I am trying to get contact name using phone number but it returns null when the contact is in sim.
This is my code:
fun getContactName(phone: String): String{
val query = Contacts.getQuery()
query.whereEqualTo(Contact.Field.PhoneNumber, phone)
val contacts = query.find()
return if (contacts.isNotEmpty())
contacts[0].displayName
else
""
}
Fatal Exception: java.lang.RuntimeException: Parcel: unable to marshal value com.github.tamir7.contacts.Contact@bafece
at android.os.Parcel.writeValue(Parcel.java:1711)
at android.os.Parcel.writeList(Parcel.java:865)
at android.os.Parcel.writeValue(Parcel.java:1658)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:777)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506)
at android.os.Bundle.writeToParcel(Bundle.java:1181)
at android.os.Parcel.writeBundle(Parcel.java:817)
at android.support.v4.app.FragmentState.writeToParcel(Unknown Source:53)
at android.os.Parcel.writeTypedArray(Parcel.java:1401)
at android.support.v4.app.FragmentManagerState.writeToParcel(Unknown Source:2)
at android.os.Parcel.writeParcelable(Parcel.java:1730)
at android.os.Parcel.writeValue(Parcel.java:1636)
at android.os.Parcel.writeArrayMapInternal(Parcel.java:777)
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506)
at android.os.Bundle.writeToParcel(Bundle.java:1181)
at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4617)
at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3998)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Hi ,
Great library first of all very useful.
I have tested this library on couple of devices but on some i cant get contacts at all for example: AM405, HTC , Galaxy J2.
Does this library supports contacts from sources like SIM, local, or Google/CardDav accounts ? or just local ?
Thanks
its normal that getNumber
return normalizedNumber
?
class PhoneNumber
/**
* Gets the phone number.
*
* @return phone number.
*/
public String getNumber() {
return normalizedNumber;
}
/**
* Gets the normalized phone number.
*
* @return normalized phone number.
*/
public String getNormalizedNumber() {
return normalizedNumber;
}
Hi,
When i retrieve the list of contacts i am getting all the contacts for all my accounts in device. e.g. My friend's name is "Smith John" and he is registered on WhatsApp and Skype. So after i make query, it shows WhatsApp, Skype, Phone device only and google contact with same name but 4 times in result. So my basic question is as below.
Is it possible to load the contacts only associated with WhatsApp?
Please ask me any question if you got any doubts.
Thanks,
Ankur
Some devices store the phone numbers with spaces in the contacts db, which makes it currently impossible to search for unless you know where the exact spaces are.
There should be a method or it should always remove spaces when comparing.
E.g.
Phone storage Contact.Field.PhoneNumber = "123 456 789"
To find this contact I can't use whereEqualTo("123456789")
cos it won't match
@tamir7 Are you planning to host the repository on some other platform such as mavenCentral
, as jCenter
will officially be discontinued starting May, 1st?
Behavior: Pass date to Contacts API which fetches all contacts with ContactsContract.Contacts.CONTACT_LAST_UPDATED_TIMESTAMP later than passed value.
Usage: This would be a useful enhancement to detect changes to the contact database. Whenever a Content Observer detects a change in the contacts database, it could fetch the changed contacts based on the CONTACT_LAST_UPDATED_TIMESTAMP. This allows for efficient contacts management as it removes the need to iterate through the entire contacts library when changes are detected.
Hi,
Is there any reason for the minApi 16 ?
Cheers
This will add the ability to search Whatsapp or Telegram contacts.
Hi @tamir7.
First off, good work with this great library.
Would you consider support for retrieving the lookup key?
And possibly a findContact(String lookupKey)
method?
Example :
In device Krupa (9980224695,7091977222) but if i hit Contacts.getQuery().find() all
In my app it showing Krupa (9980224695,7091977222)
Krupa 9980224695
Krupa 7091977222
it showing 3 contacts with same name
Hi, this library simplifies the task of getting the contacts on android devices.. can you extend it to obtain birthdates of these contacts?
If a contact has multiple numbers, getNormalizedNumber() fails to get the number and returns null instead.
The new update needs to be published to a library and the version number incremented.
Hello,
I'm making a simple query such as :
Query q = Contacts.getQuery();
List<Contact> contacts = q.find();
Some of the contacts don't have PhoneNumbers populated whereas it is filled on the System stock Contact application.
Any idea ?...
Cheers
In the latest version Contact.InternalField.ContactId
was moved to Contact.Field.ContactId
causing Query.buildProjection()
to exclude this field if not added when calling Query.include()
.
When iterating through the cursor in Query.find(ids)
, CursorHelper.getContactId()
will always return null causing the contactsMap
to be overriden with every new Contact.
IMO, adding projection.add(Contact.Field.ContactId.getColumn());
to Query.buildProjection()
should do the trick
Now that there is an id field visible within the Contact, do you intend on making the find contact by id a public query?
If not, how do you currently pass the Contact object to a new activity without it being a Parceable object? Do you just pass the display name to the new activity and then make query to find the Contact that way?
Thanks
Awesome library, able to fetch contacts fast. Is it possible to make the Contact object serializable? I am storing it in an array list and was hoping to pass it to every activity.
The following code is resulting in contacts that never have a first name, but I know that some of them do:
Query q = Contacts.getQuery();
q.hasPhoneNumber();
q.include(Contact.Field.DisplayName, Contact.Field.GivenName, Contact.Field.FamilyName);
List<Contact> contacts = q.find();
for (Contact contact : contacts) {
Log.d(TAG, "Display: " + contact.getDisplayName());
if (contact.getGivenName() != null) {
Log.d(TAG, "First: " + contact.getGivenName());
}
if (contact.getFamilyName() != null) {
Log.d(TAG, "Last: " + contact.getFamilyName());
}
Log.d(TAG, "\n");
}
Am I missing something, or is there a bug?
Hey,
I'm trying to display a contact's photoUri using UIL, and it's failing with the following FailReason:
java.lang.IllegalArgumentException:` URI: content://com.android.contacts/contacts/54971/photo/photo, calling user: , calling package:
Do you have any idea why this might happen?
If not, how would you suggest displaying photos retrieved from Contacts using contact.getPhotoUri()?
Thanks!
Please add and delete a contact features
Hello , I want to get all contacts with only mobile type number. How can I do this ?
you must edit this to
List<Contact> contacts = Contacts.getQuery().find();
Please contact id field to compare contact
Like for e.g. adding adding or removing an area code from an phone number for a specific contact.
Are you still maintaining this?
If you no longer have time, I'd love to help.
I'm trying to fetch the last updated timestamp of contacts but can't seem to find a way to include a field that's not available in this library.
Is this feature not available yet?
We are building an app relying on this library to load device contacts. But problem arise when user have more than 3000 contacts in their device. I think it would be great if you can provide a limit function in this library. I know that you are using ContentResolver to load your contact, but there should be a way to limit the query.
Thanks
Issue kind: BUG
Version: 1.1.3
While using where clause you should escape your query with
DatabaseUtils.sqlEscapeString(query)
or
query.replaceAll("'", "\'\'")
otherwise if LIKE operator of this query 'lior
will raise
Caused by: java.lang.IllegalArgumentException: Unterminated quote in '( display_name LIKE '%'lior%' AND mimetype IN ('vnd.android.cursor.item/phone_v2', 'vnd.android.cursor.item/email_v2') )'
Great library!
But sometimes I need to query for the First name and Last name separately.
Any plans to add such a feature?
Thanks!
java.lang.IllegalStateException: Contacts library not initialized
Hey great work.....!!! but I want to use some other filelds value from contact book like relation,organisation and note so how I can get the values of relation,organisation and note fields from contact book please guide me how i can get these values
Address, city, country, ...
I have used below query to get all contact list, but some mobile email address is missing.
Query q = ContactsList.getQuery();
q.find()
Are there access to the web address urls, the notes, and the groups for the Contact?
Hello,
your API is very beautiful and easy to use. Thanks. Can you add event listeners for contact update or contact add which brings back that contact that was updated or added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.