Android SMS show contact name by recipient_ids -
the code snippet below returns basic sms conversation data:
cursor cursor = activity.getcontentresolver().query(uri.parse( "content://mms-sms/conversations?simple=true"), null, null, null, "normalized_date desc" ); if(cursor.movetofirst()) string recipient_ids = cursor.getstring(3);
my question how can phone's contact data given recipient_ids? in case need retrieve contact number , contact display_name.
your appreciated. in advance!
try this:
public string getcontactdata(string id){ string number; cursor phones = fa.getcontentresolver().query(contactscontract.commondatakinds.phone.content_uri, null, contactscontract.commondatakinds.phone.contact_id +" = "+ id, null, null); if(phones.movetofirst()) { number = phones.getstring(phones.getcolumnindex(contactscontract.commondatakinds.phone.number)); } phones.close(); return number; }
hope helps!
Comments
Post a Comment