Windows Phone 8.1 聯系人與日歷


(1)聯系人(Manifest 獲取權限)

1)獲取聯系人

獲取聯系人的方式有兩種

A. ContactPicker

ContactPicker 也就是直接打開一個系統的選擇聯系人界面,讓用戶選擇,可設置單選或多選:

var contactPicker = new ContactPicker();

contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber);

//Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactsAsync();
Windows.ApplicationModel.Contacts.Contact contact = await contactPicker.PickContactAsync();
if( contact != null )
{
    MessageDialog dialog = new MessageDialog(string.Format("Phone Number: {0}", contact.Phones.First().Number), contact.DisplayName);
    await dialog.ShowAsync();
}

必須設置唯一的一個 ContactFieldType。

B. ContactManager

可通過 ContactManager API 直接搜索某聯系人:

ContactStore contactStore = await ContactManager.RequestStoreAsync();
var list = await contactStore.FindContactsAsync(searchTextBox.Text.Trim());

獲取的聯系人列表為只讀的。

2)與聯系人聯系

可直接向聯系人撥打電話、發送短信、發送郵件:

PhoneCallManager.ShowPhoneCallUI("15911111111", "Some");

ChatMessage message = new ChatMessage();
message.Recipients.Add("15911111111");
message.Body = "Test.";
await ChatMessageManager.ShowComposeSmsMessageAsync(message);

EmailMessage email = new EmailMessage();
email.To.Add(new EmailRecipient("aaa@qq.com"));
email.Body = "Test.";
await EmailManager.ShowComposeNewEmailAsync(email);

 

(2)日歷

1)直接打開系統的日歷應用

比如打開日歷主界面:

await AppointmentManager.ShowTimeFrameAsync(DateTimeOffset.Now, TimeSpan.FromHours(1));

 

2)API 方式

比如新建一個日歷事件:

Appointment appointment = new Appointment();
appointment.Subject = "";
appointment.StartTime = DateTimeOffset.Now;
//...
await AppointmentManager.ShowAddAppointmentAsync(appointment, new Rect());

更多 API :鏈接


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM