Android 传递图像url以创建新的联系人活动
您好,我正在尝试使用预填充的数据调用createcontact表单,并能够输入基本的详细信息。我可以输入姓名、电子邮件、电话号码,但无法加载联系人的缩略图。守则的有关部分如下:Android 传递图像url以创建新的联系人活动,android,android-contacts,Android,Android Contacts,您好,我正在尝试使用预填充的数据调用createcontact表单,并能够输入基本的详细信息。我可以输入姓名、电子邮件、电话号码,但无法加载联系人的缩略图。守则的有关部分如下: // Creates a new intent for sending to the device's contacts application Intent insertIntent = new Intent(ContactsContract.Intents.Insert.ACTION);
// 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);
关于如何做到这一点的任何指示。谢谢 我认为使用Insert intent是实现这一目标的关键 您正在使用
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"
下面是一个完整的例子,解释了您要寻找的内容
@感谢pratik指向此链接和url。我已经浏览了您提供的链接。看起来是直接将联系人添加到数据库中,但我要找的是,我使用预先设置的缩略图图像转到AddContactActivity。如果您能为我指一些带缩略图到AddContactActivity的内容,那就太好了预设。我会再调查一遍,然后告诉你。如果在这上面发现什么,请告诉我。