VCARD3.0通讯录名片在Android系统…
来源:互联网 发布:剪刀手软件 编辑:程序博客网 时间:2024/05/22 05:30
研究了几天VCARD3.0,发现网上资料太少,特别是在Android平台的。特此记录。
public static voidmain(String[] args) throws Exception {
OutputStreamWriter writer = newOutputStreamWriter( newFileOutputStream("example.vcard"), "UTF-8");
VCardComposer composer = newVCardComposer();
//create a contact ContactStruct contact1 = newContactStruct(); contact1.name = "WuYusheng"; contact1.company = "The Company"; contact1.addPhone(Contacts.Phones.TYPE_MOBILE,"+861888888888", null, true);
//create vCard representation String vcardString =composer.createVCard(contact1,VCardComposer.VERSION_VCARD30_INT);
//write vCard to the output stream writer.write(vcardString); writer.write("\n"); //add empty lines betweencontacts
// repeat for other contacts // ...
writer.close(); }
//run the WriteExamplefirst or provide your own "example.vcard"
public static voidmain(String[] args) throws Exception {
VCardParser parser = new VCardParser(); VDataBuilder builder = newVDataBuilder();//VDataBuilder("UTF-8", "UTF-8", false);
String file = "example.vcard";
//read whole file to string BufferedReader reader = new BufferedReader(newInputStreamReader( new FileInputStream(file),"UTF-8")); String vcardString = ""; String line; while ((line = reader.readLine()) != null){ vcardString += line + "\n"; } reader.close();
//parse the string boolean parsed = parser.parse(vcardString,"UTF-8", builder); if (!parsed) { throw newVCardException("Could not parse vCard file: " + file); }
//get all parsed contacts List pimContacts = builder.vNodeList;
//do something for all the contacts for (VNode contact : pimContacts) { ArrayListprops = contact.propList;
//contactname - FN property Stringname = null; for(PropertyNode prop : props) { System.out.println(prop.propName + ":" +prop.propValue); }
//similarly for other properties (N, ORG, TEL, etc) //... } System.out.println("ReadSuccesssssss!"); }
输出名片类范例:
public class WriteExample {
}
输入名片类范例:
public class ReadExample {
}
以上范例基于android-vcard.jar实现,带源码。有兴趣可以私信沟通交流学习。
0 0
- VCARD3.0通讯录名片在Android系统…
- Android通讯录名片扫描识别技术SDK
- Android名片扫描识别系统SDK
- android调用系统通讯录
- android系统 通讯录路径
- Android 调用系统通讯录
- android 读取系统通讯录
- Android中获取系统通讯录联系人并显示在EditText
- Android中获取系统通讯录联系人并显示在EditText
- Android中获取系统通讯录联系人并显示在EditText
- Android中获取系统通讯录联系人并显示在EditText
- android 内容提供者 系统通讯录
- android 跳转到系统通讯录
- 名片视图 - 天涯人脉通讯录2010
- AH名片簿客户通讯录管理软件3.78
- vcard通讯录格式及手机名片制作
- 通讯录名片扫描识别的功能SDK
- 调用android系统通讯录 添加一条通讯录数据
- zip error: Invalid&nbs…
- EL表达式详解
- Cloudera Apache Hadoop 管理员培训上海站 课程内容揭晓!
- ArcGIS、Super、MapMapInfo…
- ArcGIS、Super、MapMapInfo…
- VCARD3.0通讯录名片在Android系统…
- Android学习笔记之AndroidMa…
- android color.xml
- android JNI
- Android_照相机Camera_调用系统照…
- use curl to upload file with remote php file
- 将博客搬至CSDN
- 199. Binary Tree Right Side View
- 阿里小蜜技术学习笔记--知识点整理