Android 3.0 - How to retrieve ALL contacts via ContactsContract -
Android 3.0 - How to retrieve ALL contacts via ContactsContract -
i working on android honeycomb (v3.0) application has requirement of displaying contacts stored within google business relationship registered on device. 1 of problems having can retrieve contacts available within "my contacts", "starred in android", , "other contacts". able retrieve contacts "directory". believe "directory" section feature provided google organizations , companies wish provide directory of members/employees within domains others. please see screenshot below:
so far, have next line in manifest file:
<uses-permission android:name="android.permission.read_contacts" />
i have tried using code:
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)); } cursor.close();
in case, "my contacts" , "starred in android" empty. however, (1) contact in "other contacts" obtained. "directory" contains hundreds of contacts not retrieved, though.
my question: there way create sure contacts in "directory" retrieved well? know can re-create contacts on using web browser , sync them device, if new contact added "directory", have manually every time, not great selection me. please advise.
look @ next code
import android.app.activity; import android.content.contentresolver; import android.database.cursor; import android.os.bundle; import android.provider.contactscontract; public class testcontacts extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); contentresolver cr = getcontentresolver(); cursor cur = cr.query(contactscontract.contacts.content_uri, null, null, null, null); if (cur.getcount() > 0) { while (cur.movetonext()) { string id = cur.getstring(cur .getcolumnindex(contactscontract.contacts._id)); string name = cur .getstring(cur .getcolumnindex(contactscontract.contacts.display_name)); if (("1") .equals(cur .getstring(cur .getcolumnindex(contactscontract.contacts.has_phone_number)))) { cursor pcur = cr.query( contactscontract.commondatakinds.phone.content_uri, null, contactscontract.commondatakinds.phone.contact_id + " = ?", new string[] { id }, null); int = 0; int pcount = pcur.getcount(); string[] phonenum = new string[pcount]; string[] phonetype = new string[pcount]; while (pcur.movetonext()) { phonenum[i] = pcur .getstring(pcur .getcolumnindex(contactscontract.commondatakinds.phone.number)); phonetype[i] = pcur .getstring(pcur .getcolumnindex(contactscontract.commondatakinds.phone.type)); i++; } }
android android-3.0-honeycomb android-contacts contactscontract google-contacts
Comments
Post a Comment