我知道如何獲得Android上的所有聯繫人,但是如果我選擇聯繫人,我無法獲得聯繫人所需的聯繫人。例如:我有4個接觸如果我選擇聯繫人,我沒有得到我的意思
joe have phone number 7889 987;
erick have phone number 8792 871;
nona phone number 3653 872 and 2345 907;
rina phone number 8796 235;
如果我選擇喬,我得到NONA的電話號碼= 2345 907 我不知道什麼是對我的應用程序的問題。
這是我的代碼
public void tambahPenerima (View v) {
Intent i = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
i.setType(ContactsContract.Contacts.CONTENT_TYPE);
startActivityForResult(i, PICK_CONTACT);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK) {
Cursor cursor = null;
String name = "";
String number = "";
cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
while(cursor.moveToNext()) {
name = cursor.getString(cursor.getColumnIndex((ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME)));
number = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
}
if(cursor!=null) {
cursor.close();
}
Intent kirimPesan = new Intent();
kirimPesan.setClass(this, kirimPesan.class);
kirimPesan.putExtra("nama", name);
kirimPesan.putExtra("nomor", number);
kirimPesan.putExtra("chiper", chiper);
startActivity(kirimPesan);
}
}
有人請幫助我,我真的需要幫助。 對不起,我英文很差。 感謝..
我曾嘗試烏爾建議,但我的輸出與我上面的代碼相同。還有什麼建議?請.. – androidDev 2013-03-12 12:29:45