Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ContactsContract.Contacts.IN_VISIBLE_GROUP mean in Android?

From the Android developer documentation, this is all I got:

An indicator of whether this contact is supposed to be visible in the UI. "1" if the contact has at least one raw contact that belongs to a visible group; "0" otherwise.

Essentially what does this mean? What is the purpose of using this flag?

I have tried experimenting with contacts for quite a good amount of time and the results look confusing. When I fetch contacts with this flag ON, it fetches contacts that I believe are the latest synced contacts with my Google account, plus the one that I added locally in my default phone book. For example, this fetches around 912 contacts.

However, with this flag OFF, I get a huge amount of contacts, some which I hardly recognize and don't get it why they are here in the first place. This fetches around 3050 contacts!

Appreciate any help!

like image 349
Taslim A. Khan Avatar asked Oct 20 '22 17:10

Taslim A. Khan


1 Answers

Android Contacts are stored within Accounts (Such as Google, Yahoo, Linkedin, Microsoft Exchange), in each Account, contacts are stored in Groups (Such as Friends, Family, Business Contacts) there's also a special group for contacts that don't belong to any group, this group is usually called "All others in <group-name>").

In most contacts apps that ship with Android, a user can select a Custom view in which he can make groups in accounts visible or hidden in the main contacts screen, for example a user can choose to display the Friends group, but not the Family group in his Google Contacts account.

This selection will be referenced by the app querying for contacts by using the IN_VISIBLE_GROUP field, it'll be true if a contact is a part of at least one visible group. The special All others in group is almost always not a visible group, and so it's usually hidden from the Contacts app.

Specifically in Google, whenever you email someone or get an email from someone, the email address is automatically added to your contacts, to the All others in group, that's why you're probably getting a huge amount of contacts when querying without that flag.

like image 90
marmor Avatar answered Oct 22 '22 07:10

marmor