locked
Retrieve Contact thumbnail image from People App in Windows 8 Metro RRS feed

  • Question

  • In my Metro App, I use below code to retrieve contact name from People's App:

    function selectContact() {    var picker = Windows.ApplicationModel.Contacts.ContactPicker();    picker.commitButtonText = "Select";    picker.selectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.contacts;            picker.pickMultipleContactsAsync().done(function (contacts) {        if(contacts.length>0){            var j =document.getElementById("contactlist");            contacts.forEach(function (contact) {                j.innerHTML += contact.name + "<br>";            });}

    Now, I need to retrieve contact thumbnail image and add it to my application. There is a getThumbnailAsync() method for contacts but I'm not sure how to use it... I used below code but thumbnail.size is always zero:

    contacts.forEach(function (contact) {        contact.getThumbnailAsync().done(function (thumbnail) {            if (thumbnail.size > 0) {                var imageBlob = window.URL.createObjectURL(thumbnail,false);                document.getElementById("contactlist").innerHTML += "<img id=" + i + " /><br>";                document.getElementById(i).src = imageBlob;                i++;            }        });    });

    Can you help me understand how to retrieve contact image and add it to my app? I believe People app does not pass the image right now, because when I select a contact the contact image does not show up in the selected contact section in the buttom of the page

    Sunday, June 24, 2012 8:12 PM

Answers

All replies