How can I get the "provider" (skype/whatsapp/google) of the contact/phone-number

Viewed 576

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,
};
1 Answers

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...

Related