Android ACTION_PICK具体联系人的电话号码

时间:2013-07-18 14:48:57

标签: android android-contacts android-implicit-intent

我知道如何创建让联系人应用显示特定联系人的意图:

Intent intent = new Intent(Intent.ACTION_VIEW);  
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, mMyLookupKey);
intent.setData(uri);
startActivity(intent);

我也知道如何创建一个意图让联系人应用程序让我拨打电话号码:

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI)
// Explicitly set the 'type' to 'phone numbers' //
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);    
startActivityForResult(intent, REQUEST_PHONENR);

刚才我一直试图将这些结合起来,以便从特定的联系人中选择一个电话号码:

Intent intent = new Intent(Intent.ACTION_PICK); 
Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_LOOKUP_URI, mMyLookupKey);
intent.setData(uri);
// Explicitly set the 'type' to 'phone numbers'
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);    
startActivityForResult(intent, REQUEST_PHONENR);

有人知道这是可能的吗?

1 个答案:

答案 0 :(得分:0)

Intent pickContactIntent = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
                        pickContactIntent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE);
startActivityForResult(pickContactIntent, 0);