title: How to insert contacts with city, street, postal code, country in Xamarin Android using intent and activity?
body: <p>I need to programmatically open the android contacts app using an intent with Xamarin Forms/Android. When the Add New Contact activity/screen comes up, I would like to pre-populate it with the following fields:</p>
  
  <ul>
  <li>Name (this is populating)</li>
  <li>Phone (this is populating)</li>
  <li>Street (Not populating)</li>
  <li>City (Not populating)</li>
  <li>State (Not populating)</li>
  <li>Country (Not seeing a field for this, not populating)</li>
  </ul>
  
  <p>As stated above, some screens are populating, but the address fields are not. This is the Xamarin C# Android code/service being used to trigger the activity for opening up Android's 'Add Contact' screen:</p>
  
  <pre><code> public void AddContact(string name, string[] phoneNumbers, string streetAddress, string city, string state, string postalCode, CountryValues countrycode)
      {
          // get current activity
          var activity = CrossCurrentActivity.Current.Activity;
  
          // create add contact intent
          var intent = new Intent(Intent.ActionInsert);
          intent.SetType(ContactsContract.Contacts.ContentType);
  
          // add field for contact name
          intent.PutExtra(ContactsContract.Intents.Insert.Name, name);
  
          // Adding more than on phone number if available
          foreach (string numbers in phoneNumbers)
          {
              intent.PutExtra(ContactsContract.Intents.Insert.Phone, numbers);
          }
  
          // pre-populate address fields
          intent.PutExtra(ContactsContract.CommonDataKinds.StructuredPostal.Street, streetAddress);
          intent.PutExtra(ContactsContract.CommonDataKinds.StructuredPostal.City, city);
          intent.PutExtra(ContactsContract.CommonDataKinds.StructuredPostal.Region, state);
          intent.PutExtra(ContactsContract.CommonDataKinds.StructuredPostal.Postcode, postalCode);
          intent.PutExtra(ContactsContract.CommonDataKinds.StructuredPostal.Country, countrycode.ToString());
  
          //start activity
          activity.StartActivity(intent);
      }
  </code></pre>
  
  <p>The activity does open the 'add new contact' screen in the contacts app, but only the name and the phone number fields are populated. See screenshots below:</p>
  
  <p><a href="https://i.stack.imgur.com/DQfhb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DQfhb.png" alt="Populated fields"></a></p>
  
  <p><a href="https://i.stack.imgur.com/MBKbI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MBKbI.png" alt="Fields not populated"></a></p>
  
  <p>I found a link that may translate into Xamarin.Android but I have been struggling with the implementation <a href="http://www.javased.com/index.php?source_dir=MIT-Mobile-for-Android/src/edu/mit/mitmobile2/people/PeopleDetailActivity.java" rel="nofollow noreferrer">Java Samples</a>.</p>