1
我用下面的代碼在我的Metro應用檢索來自人民的App聯繫人姓名:檢索聯繫人縮略圖在Windows 8地鐵
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>";
});
}
現在,我需要檢索聯繫人縮略圖並將其添加到我的應用程序。沒有爲接觸getThumbnailAsync()方法,但我不知道如何使用它...我用下面的代碼,但thumbnail.size始終爲零:
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++;
}
});
});