2016-08-31 4 views
2

上の連絡先のリストを取得します。私はコンタクトピッカーを使いたくない。私は、すべての連絡先を繰り返して自分の名前と電話番号にアクセスし、それをリストに格納する必要があります。 (のWhatsAppが連絡先リストを読み、自分のアプリでそれを表示することができる方法と同様に)私は、Windows 10の電話での連絡先リストを読む方法を知る必要が午前のWindows 10の電話

+0

うん、私たちすべてがこれを行うにしたいです。これまでに何を試しましたか? APIが存在するかどうか知っていますか? –

答えて

1

私は別の答えhereからいくつかのコードを撮影してきました。あなたが連絡先を得ることができる必要があります。このコードで

public async Task IterateThroughContactsForContactListId() 
{    
      ContactStore allAccessStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); 

      var contacts = await allAccessStore.FindContactsAsync(); 
      foreach (var contact in contacts) 
      { 
       //process aggregated contacts 
       if (contact.IsAggregate) 
       { 
        //here contact.ContactListId is "" (null....)     
        //in this case if you need the the ContactListId then you need to iterate through the raw contacts 
        var rawContacts = await allAccessStore.AggregateContactManager.FindRawContactsAsync(contact); 
        foreach (var rawContact in rawContacts) 
        { 
         //Here you should have ContactListId 
         Debug.WriteLine($"aggregated, name: {rawContact.DisplayName }, ContactListId: {rawContact.ContactListId}"); 
        } 
       } 
       else //not aggregated contacts should work 
       { 
        Debug.WriteLine($"not aggregated, name: {contact.DisplayName }, ContactListId: {contact.ContactListId}"); 
       } 
      } 

} 

彼はまた、ノート:

そして非常に重要:appxmanifestでは、連絡先に 機能を追加する必要があります。ソリューションエクスプローラと「コードの表示」 でそれに右をクリックし、機能の下で、このためのUIはありません

<uap:Capability Name="contacts" /> 

を置きます。 thisを参照してください。

+0

ありがとう、それは私が必要としたものであり、その作業はうまくいきます。 – sme

関連する問題