我正在开发一个用于数字化目的的名片阅读器应用程序。我已经成功地以XML的形式获得了识别结果。我还解析了该XML文件,并提取出诸如姓名、电子邮件、手机号码等字段。
如何通过应用程序将此数据保存在我的手机联系人中?
发布于 2017-06-19 17:33:36
// 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);发布于 2017-06-19 17:29:35
发布于 2017-06-19 17:40:53
创建新的Intent:
Intent intent = new Intent(Intents.Insert.ACTION);
intent.setType(ContactsContract.RawContacts.CONTENT_TYPE);在你的意图中加入一些Extras,比如电子邮件或PHONE_TYPE:
intent.putExtra(Intents.Insert.EMAIL, "email@email.com");
intent.putExtra(Intents.Insert.PHONE, "15417543010");别忘了在最后启动Activity:
startActivity(intent);https://stackoverflow.com/questions/44626758
复制相似问题