如何在 Windows Phone 8.1 通用应用程序中的联系人中创建新联系人 [英] How can create a new contact in Contact in windows phone 8.1 uinversal app

查看:31
本文介绍了如何在 Windows Phone 8.1 通用应用程序中的联系人中创建新联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Windows Phone 8.1 通用应用程序中创建新联系人?目前联系人存储只支持通过id查找联系人或从联系人存储中获取所有联系人?

Is there a way to create a new contact in windows phone 8.1 universal app? currently contact store only supports find a contact by id or get all contacts from contact store?

推荐答案

啊!经过一番搜索找到了解决方案.应用可以创建自己的联系人存储,这些存储出现在 Windows Phone 人员应用中.您只需要以下代码即可添加联系人....

Ah! found the solution after some search. App can create their own contact store which appear in Windows Phone people app. All you need the following code to add contact....

using Windows.Phone.PersonalInformation;

 public async void CreateContact()
    {

        var contactStore = await ContactStore.CreateOrOpenAsync(ContactStoreSystemAccessMode.ReadWrite,ContactStoreApplicationAccessMode.LimitedReadOnly);
        var createContactQuery = contactStore.CreateContactQuery();

        ContactInformation ci = new ContactInformation();
        ci.DisplayName ="Muhammad saifullah";

      ///Save Thumbnail image.
       HttpClient client = new HttpClient();
        var data = await client.GetInputStreamAsync(new Uri("imageurlhere"));
        await ci.SetDisplayPictureAsync(data);

        StoredContact sc = new StoredContact(contactStore, ci);
        IDictionary<string, object> props = await sc.GetPropertiesAsync();
        props.Add(KnownContactProperties.Email, "myemail@domcin.com");
        props.Add(KnownContactProperties.MobileTelephone, "+1000000101001");
        props.Add(KnownContactProperties.JobTitle, "---");


        await sc.SaveAsync();           

    }

这篇关于如何在 Windows Phone 8.1 通用应用程序中的联系人中创建新联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆