我只想获得有电话号码的用户的电子邮件ID。 所以我必须得到用户的电子邮件ID,其编号类似于986879899.so plz建议我解决这个问题或从我得到解决方案的任何链接。
我想补充一点,如何让人联系不。通过推荐我的联系人列表中的人名从我的电话中获取。
答案 0 :(得分:2)
This is the solution of the above problem. Ashutosh given me the solution of the problem.
Cursor emails = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId, null, null);
while (emails.moveToNext()) {
// This would allow you get several email addresses
String emailAddress = emails.getString(
emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
System.out.println("email address might be"+emailAddress);
}
emails.close();
Thanks Ashutosh :)
答案 1 :(得分:0)
它将是这样的
Cursor cursor = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.NUMBER + " = ?", new String[]{"986879899"}, null);
cursor.moveToFirst();
cursor.getString(cursor.getColumnIndexOrThrow(PhoneLookup.Email));
您需要添加阅读联系人的权限