private void getContacts(String parameters)
    {
      try
      {
        //Get All Device Contacts
        Microsoft.Phone.UserData.Contacts cons = new Microsoft.Phone.UserData.Contacts();

        cons.SearchCompleted += (sender, e) =>
        {
          //serialize the contacts in json format
          string jsonContacts = JsonConvert.SerializeObject(e.Results);

          //call the callback
          executeCallback(jsonContacts);
        };

        //Search the phone for contacts
        cons.SearchAsync(String.Empty, Microsoft.Phone.UserData.FilterKind.None, "#1");
      }
      catch (Exception e)
      {
        e.ToString();
        System.Diagnostics.Debugger.Break();
      }
    }
 public Task<bool> RequestPermission()
 {
   return Task<bool>.Factory.StartNew(() =>
   {
     try
     {
       var contacts = new Microsoft.Phone.UserData.Contacts();
       contacts.Accounts.ToArray(); // Will trigger exception if manifest doesn't specify ID_CAP_CONTACTS
       return true;
     }
     catch (Exception)
     {
       return false;
     }
   }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
 }
Ejemplo n.º 3
0
 public Task <bool> RequestPermission()
 {
     return(Task <bool> .Factory.StartNew(() =>
     {
         try
         {
             var contacts = new Microsoft.Phone.UserData.Contacts();
             contacts.Accounts.ToArray(); // Will trigger exception if manifest doesn't specify ID_CAP_CONTACTS
             return true;
         }
         catch (Exception)
         {
             return false;
         }
     }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default));
 }