Reputation: 31
I am working on a business card reader app for digitalizing purposes. I have successfully got the recognition result in the form of XML. I have also parsed that XML file and extracted out the fields such as name, email, mobile no.
How can I save this data in my phone contact via my app?
Upvotes: 2
Views: 4223
Reputation: 3971
Create a new Intent
:
Intent intent = new Intent(Intents.Insert.ACTION);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
Put some Extras
in your intent like EMAIL or PHONE_TYPE :
intent.putExtra(Intents.Insert.EMAIL, "[email protected]");
intent.putExtra(Intents.Insert.PHONE, "15417543010");
and don't forget at the end to start the Activity
:
startActivity(intent);
Upvotes: 0
Reputation: 712
// Creates a new Intent to insert a contact
Intent intent = new Intent(Intents.Insert.ACTION);
// Sets the MIME type to match the Contacts Provider
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);
/*
* Inserts new data into the Intent. This data is passed to the
* contacts app's Insert screen
*/
// Inserts an email address
intent.putExtra(Intents.Insert.EMAIL, mEmailAddress.getText())
/*
* In this example, sets the email type to be a work email.
* You can set other email types as necessary.
*/
.putExtra(Intents.Insert.EMAIL_TYPE, CommonDataKinds.Email.TYPE_WORK)
// Inserts a phone number
.putExtra(Intents.Insert.PHONE, mPhoneNumber.getText())
/*
* In this example, sets the phone type to be a work phone.
* You can set other phone types as necessary.
*/
.putExtra(Intents.Insert.PHONE_TYPE, Phone.TYPE_WORK);
Source: Insert a New Contact Using an Intent
Upvotes: 2