2017-07-24 1 views
0

Il existe un moyen d'enregistrer le nom du pays dans un contact en utilisant Intention? Im essayant avec ce code:Enregistrer le pays dans l'intention de contact

Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION); 
    intent.setType(ContactsContract.RawContacts.CONTENT_TYPE); 
    intent.putExtra(ContactsContract.Intents.Insert.NAME, contactName); 
    intent.putExtra(ContactsContract.Intents.Insert.NOTES, description); 
    intent.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.CITY, contactTown); 
    intent.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, contactCountry); 
    intent.putExtra(ContactsContract.CommonDataKinds.StructuredPostal.REGION, contactProvince); 

Mais quand je crée un nouveau contact, il vient sans VILLE, PAYS ET REGION

Je vous remercie de toute aide!

+0

essayer ce lien https://stackoverflow.com/a/18972011/3983054 –

Répondre

1

Vous avez le champ intention POSTAL pour cela, il est un champ de texte libre format:

Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION); 
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE); 
intent.putExtra(ContactsContract.Intents.Insert.NAME, contactName); 
intent.putExtra(ContactsContract.Intents.Insert.NOTES, description); 
intent.putExtra(ContactsContract.Intents.Insert.POSTAL, contactTown + ", " + contactCountry + " " + contactProvince); 
intent.putExtra(ContactsContract.Intents.Insert.POSTAL_ISPRIMARY, true);