2012-12-14 20 views
1

嗨,我試圖調用創建聯繫人表單與預填充數據,並能夠在基本的細節。我能夠輸入姓名,電子郵件,電話號碼,但我無法加載聯繫人的縮略圖。代碼的相關部分是:傳遞圖像網址來創建一個新的聯繫活動android

// 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

我認爲使用插入意圖是至關重要的。

您正在使用

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

+0

@thanks PRATIK指出這和url..i已過去雖然鏈接你provided..looks像其直接添加聯繫人到數據庫,但我所尋找的是我去AddContactActivity與縮略圖預先關聯。 – Deva

+0

如果你能指點我一些需要預覽縮略圖的AddContactActivity的東西,那就太好了。 – Deva

+0

我會再看看這個,讓你知道。 –

相關問題