我通过以下方式获取联系人列表
允许
android:name="android.permission.READ_CONTACTS"
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
但如何从
public void onActivityResult(int reqCode, int resultCode, Intent data) {
//what should i have to write to fetch email address of selected contact
// I wrote like below but i could not get result
if (resultCode == Activity.RESULT_OK) {
try{
Uri contactData = data.getData();
Cursor cursorEmail = getContentResolver().query(contactData,null,null,null,null);
cursorEmail.moveToFirst();
String emailAdd = cursorEmail.getString(cursorEmail.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS));
Toast.makeText(MySettings.this, emailAdd, Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(MySettings.this, "No Email Add found", Toast.LENGTH_LONG).show();
}
}
但问题是我没有从选定的联系人列表中获取电子邮件地址,所以任何人都可以给我解决方案