/**
* Check all contact information
* The data table is queried here
*
*/
@SuppressLint ("Newapi")
private void Findcontack () {
Contentresolver CR = This.getcontentresolver ();
Cursor cur = cr.query (Data.content_uri, NULL, NULL, NULL, "raw_contact_id");
int oldid =-1;
while (Cur.movetonext ()) {
int newId = Cur.getint (Cur.getcolumnindex (data.raw_contact_id));
The new contact foreign key has changed
if (oldid! = newId) {
oldid = newId;
}
Gets the type of the current record
String MimeType = cur.getstring (Cur.getcolumnindex (Data.mimetype));
Get name related
if (StructuredName.CONTENT_ITEM_TYPE.equals (MimeType)) {
String familyname = cur.getstring (Cur.getcolumnindex (structuredname.family_name)); Name
String givenName = cur.getstring (Cur.getcolumnindex (structuredname.given_name)); Name
Mcontactsname.add (GivenName);
Draw Contact Name
Title.settext (Mcontactsname.get (position));
Draw Contact Number
Text.settext (Mcontactsnumber.get (position));
Draw a contact Avatar
Iamge.setimagebitmap (Mcontactsphonto.get (position));
Bitmap Contactphoto = null;
Long ContactID = Cur.getlong (Cur.getcolumnindex (structuredname.contact_id));
Long photoid = Cur.getlong (Cur.getcolumnindex (structuredname.photo_id));
if (PhotoID > 0) {
Uri Uri =contenturis.withappendedid (Contactscontract.contacts.content_uri,contactid);
InputStream input = ContactsContract.Contacts.openContactPhotoInputStream (CR, URI);
Contactphoto = Bitmapfactory.decodestream (input);
}else {
Contactphoto = Bitmapfactory.decoderesource (Getresources (), R.drawable.contact_photo);
}
Mcontactsphonto.add (Contactphoto);
}
Get phone-related
else if (Phone.CONTENT_ITEM_TYPE.equals (MimeType)) {
int phonetype = Cur.getint (Cur.getcolumnindex (Phone.type));
Home Electrical Information Family Phone
if (Phonetype = = Phone.type_home) {
P.hometel = cur.getstring (Cur.getcolumnindex (Phone.number));
}
Mobile Information
else if (Phonetype = = Phone.type_mobile) {
String Mobiletel = cur.getstring (Cur.getcolumnindex (Phone.number));
Mcontactsnumber.add (Mobiletel);
}
}
Get instant (IM) information MSN QQ
else if (Im.CONTENT_ITEM_TYPE.equals (MimeType)) {
int imtype = Cur.getint (Cur.getcolumnindex (Im.protocol));
Msn
if (Imtype = = im.protocol_msn) {
P.msn = cur.getstring (Cur.getcolumnindex (im.data));
}
Qq
else if (Imtype = = im.protocol_qq) {
String QQ = cur.getstring (Cur.getcolumnindex (im.data));
LOG.I ("DD", "===qq====" +qq);
}
}
}
}
Get Contact data