0
我曾嘗試用下面的方法在我project.It做工精細挑選,從手機聯繫人挑接觸.....具有相同的名稱和兩個以上的數量
但在某些情況下,我將無法正常工作...... 對於防爆:在與像個人/家庭的多個號碼相同名稱的情況下..
在這個階段,將只挑選第一number.so我無法挑選從接觸我。請給解決方案.....
代碼在這裏
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
switch (reqCode) {
case (PICK_CONTACT) :
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null);
if (c.moveToFirst()) {
String id =c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts._ID));
String hasPhone =c.getString(c.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
if (hasPhone.equalsIgnoreCase("1")) {
Cursor phones = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ id,
null, null);
phones.moveToFirst();
cNumber = phones.getString(phones.getColumnIndex("data1"));
System.out.println("number is:"+cNumber);
}
/*name = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
Textcontact.setText(name);*/
edt.setText(cNumber);
}
}
break;
}
}
謝謝...
您是否嘗試過瀏覽'phones'光標,而不是隻讀取一個項目? – njzk2 2013-04-04 07:54:19