Does anyone know how to access contacts list in WP7 ? this is the questions i came across in many forums and websites and recently i myself came across this situation shortly and came to know that microsoft has restricted access to the Contact API's, calendar, Camera etc to the third party application developers though i really don't know why microsoft had hidden such an important APIs from the developer since most of the mobile development works revolve around accessing phone contact for many purpose.

Do microsoft open the API's to public? really don't know but Microsoft is planning to release "Mango update" SDK this month 26th and it is said that more than 1500 API's are exposed in this SDK release to acces contacts, calendar etc etc but no one really knows to what degree.

is there any way to access contacts now? the answer is no but we can get partial information of contacts using "SavePhoneNumberTask" which has a property "PhoneNumber" with which you can access few information of contact below is the sample code

First of all include name space Tasks

using Microsoft.Phone.Tasks;

and below is the function to retieve contact list

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
SavePhoneNumberTask savePhoneNumber = new SavePhoneNumberTask();
savePhoneNumber.Completed += new EventHandler(savePhoneNumber_Completed);
savePhoneNumber.PhoneNumber = "1987654320";
savePhoneNumber.Show()

void savePhoneNumber_Completed(object sender, TaskEventArgs e)

{
view sourceprint?

MessageBox.Show("Phone Number Saved");

}
Though this method calls the phone contact screen and then add the contact one by one, but this is not straight forward way to it since API doesn't allow to save contacts without opening contact list screen any way above method is crude and its better to wait until Microsoft releases "Mango SDK" for windows phone development.
0 Komentar untuk "Accessing windows phone 7 (WP7) contacts through c# programming"