您可以使用类似这样的方法来提示用户选择联系人,然后拨打哪个电话号码(如果有多个)......而不是将其传递给拨打电话的意图:
Intent intent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(intent, 1);
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Uri contactData = data.getData();
String theID = contactData.toString());
//MAKE YOUR CALL .. do whatever... example:
ContentResolver contentResolver = getContentResolver();
Uri contactData = Uri.parse(theID);
Cursor cur = contentResolver.query(contactData, null, null, null, null);
String theNumber = cur.getString(cur.getColumnIndex("data4"));
cur.close();
Intent my_callIntent = new Intent(Intent.ACTION_CALL);
my_callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
my_callIntent.setData(Uri.parse("tel:" + theNumber));
startActivity(my_callIntent);
}
}
它不漂亮也不完美,可能需要一些修改,只是有点想不通,但希望你能明白。