您好我正在尝试使用预先填充的数据调用创建联系人表单并能够输入基本详细信息。我可以输入姓名,电子邮件,电话号码,但我无法加载联系人的缩略图。代码的相关部分是:
// Creates a new intent for sending to the device's contacts application
Intent insertIntent = new Intent(ContactsContract.Intents.Insert.ACTION);
// Sets the MIME type to the one expected by the insertion activity
insertIntent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
/**
* Added this extra for 4.0 device as on save the onActivityResult was
* not getting invoked rather a new activity was invoked
**/
String INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED = "finishActivityOnSaveCompleted";
insertIntent.putExtra(INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED,
true);
// Sets the new contact name
insertIntent.putExtra(ContactsContract.Intents.Insert.NAME,
"name");
insertIntent.putExtra(ContactsContract.Intents.Insert.PHONE,
(Utility.formatPhoneNumber(mCellNumber)));
insertIntent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE,
Phone.TYPE_MOBILE);
insertIntent.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE,
(Utility.formatPhoneNumber(mOfficeNumber)));
insertIntent.putExtra(
ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE,
Phone.TYPE_WORK);
**insertIntent.putExtra(
ContactsContract.Intents.ATTACH_IMAGE,getPhotoUrl());**
// Send out the intent to start the device's contacts app in its add
// contact activity.
startActivityForResult(insertIntent,
REQUEST_CODE_ADD_NEW_CONTACT);
关于如何做到这一点的任何指针。谢谢!
答案 0 :(得分:0)
我认为使用插入意图对于实现它至关重要。
您正在使用
ContactsContract.Intents.ATTACH_IMAGE
其中解释了这个,
Starts an Activity that lets the user pick a contact to attach an image to. After picking the contact it launches the image cropper in face detection mode.
Constant Value: "com.android.contacts.action.ATTACH_IMAGE"
以下是您正在寻找的完整示例。
Programatically adding contacts with photo using Contacts Provider