3

How can I get the "phone number's contact provider" (google/skype/whatsapp/...) when I query android's contact provider?

Currently I have these fields in my projection, and I'm not able to find the field that has the "contact-provider" information about the contact/number.

import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;

static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] {
    Contacts._ID,
    Contacts.DISPLAY_NAME,
    Contacts.CONTACT_STATUS,
    Contacts.CONTACT_PRESENCE,
    Contacts.PHOTO_ID,
    Contacts.LOOKUP_KEY,
    Phone.TYPE,
    Phone.LABEL,
    Phone.NUMBER,
};
Gavriel
  • 18,880
  • 12
  • 68
  • 105

1 Answers1

1

It is quite an old question, but maybe it will help someone in the future:

Try to do the following (in Kotlin, but similar for Java):

val cursor = context.contentResolver.query(
                 ContactsContract.Contacts.CONTENT_URI,
                 arrayOf(ContactsContract.RawContacts.ACCOUNT_TYPE),
                 null,
                 null,
                 null)
while (cursor.moveToNext()) {
    Log.d(TAG, cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE)))
}

This will give you results as "com.google", "com.whatsapp", "org.telegram.messenger", etc...

lior_13
  • 577
  • 7
  • 18