Getting a list of all phone contacts?

NOTE. Should work on Android 1.5 - ContactsContract is not

A fairly simple question. I need to know the best way to get the same contact list that appears when the user clicks the "Contacts" button.

You would think something like this would work:

//For Contacts
Intent pickIntent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
this.startActivityForResult(pickIntent, RESULT);

//For Phones
Intent pickIntent = new Intent(Intent.ACTION_PICK, Phones.CONTENT_URI);
this.startActivityForResult(pickIntent, RESULT);

The problem is that it does not include secondary google accounts or Exchange contacts. Using additional accounts in Android, you can add additional gmail accounts to synchronize mail and contacts. The intention above will not list these additional contacts.

I am also told that on HTC Desire you can add contacts to your phone that are not synced with Google. These contacts are also not displayed.

, , , , Google.

. Android 1.5 - ContactsContract

+3
4

Android . . , ContactsContract, , , Android.

+3

ContactsContract.

, ContactsContract, . .

HTH!

+3

Android 2.0

Android 2.0, ContactsContract.

0
source
Cursor cursor=getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    while ( cursor.moveToNext() ) {
        String name=cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

    }
-1
source

Source: https://habr.com/ru/post/1746947/


All Articles