Android跳转系统联系人界面插入联系人 传真\地址\邮箱\职位\部门\邮编\照片

  1. private void toExecuteSave(){
  2.         Intent intent = new Intent(Intent.ACTION_INSERT);
  3.         intent.setType(“vnd.android.cursor.dir/person”);
  4.         intent.setType(“vnd.android.cursor.dir/contact”);
  5.         intent.setType(“vnd.android.cursor.dir/raw_contact”);
  6. //        //添加姓名
  7.         intent.putExtra(Insert.NAME, mEmployee.getEmployeeName()+vUserName.getText());
  8. //        intent.putExtra(Insert.NOTES,mEmployee.getUserName());
  9. //        //添加职位
  10. //        intent.putExtra(Insert.JOB_TITLE,mEmployee.getJobName());
  11. //        //添加公司名称
  12. //        intent.putExtra(Insert.COMPANY,mEmployee.getOrgName());
  13. //        //添加邮箱
  14. //        intent.putExtra(Insert.EMAIL_TYPE,Email.TYPE_WORK);
  15. //        intent.putExtra(Insert.EMAIL,mEmployee.getOfficeEmail());
  16. //        //添加手机
  17. //        intent.putExtra(Insert.PHONE_TYPE,Phone.TYPE_WORK_MOBILE);
  18. //        intent.putExtra(Insert.PHONE, mEmployee.getMobile());
  19. //        //添加办公电话
  20. //        intent.putExtra(Insert.SECONDARY_PHONE_TYPE,Phone.TYPE_WORK);
  21. //        intent.putExtra(Insert.SECONDARY_PHONE, mEmployee.getOfficeTel());
  22. //        //添加传真
  23. //        intent.putExtra(Insert.TERTIARY_PHONE_TYPE,Phone.TYPE_FAX_WORK);
  24. //        intent.putExtra(Insert.TERTIARY_PHONE, mEmployee.getFax());
  25. //        //添加地址
  26. //        intent.putExtra(Insert.POSTAL,mEmployee.getAddress());
  27. //        intent.putExtra(Insert.POSTAL_TYPE,StructuredPostal.TYPE_WORK);
  28.         ArrayList<ContentValues> data = new ArrayList<ContentValues>();
  29.         ContentValues values1 = new ContentValues();
  30.         values1.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
  31.         values1.put(StructuredName.PHONETIC_GIVEN_NAME, mEmployee.getEmployeeName());
  32.         values1.put(StructuredName.GIVEN_NAME, mEmployee.getEmployeeName());
  33.         values1.put(StructuredName.DISPLAY_NAME, mEmployee.getEmployeeName());
  34.         data.add(values1);
  35.         // 添加用户名 职位 部门
  36.         ContentValues values2 = new ContentValues();
  37.         values2.put(Data.MIMETYPE, Organization.CONTENT_ITEM_TYPE);
  38.         values2.put(Organization.LABEL, mEmployee.getUserName());
  39.         values2.put(Organization.TITLE, mEmployee.getJobName());
  40.         values2.put(Organization.COMPANY, mEmployee.getOrgName());
  41.         values2.put(Organization.TYPE, Organization.TYPE_WORK);
  42.         data.add(values2);
  43.         // 添加邮箱
  44.         ContentValues values3 = new ContentValues();
  45.         values3.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
  46.         values3.put(Email.DATA, mEmployee.getOfficeEmail());
  47.         values3.put(Email.TYPE, Email.TYPE_WORK);
  48.         data.add(values3);
  49.         // 添加手机
  50.         ContentValues values4 = new ContentValues();
  51.         if (mEmployee.getMobile().contains(“或”)) {
  52.             final String[] tNumbers = mEmployee.getMobile().split(“或”);
  53.             for (String tNum : tNumbers) {
  54.                 values4.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  55.                 values4.put(Phone.NUMBER, tNum);
  56.                 values4.put(Phone.TYPE, Phone.TYPE_WORK_MOBILE);
  57.             }
  58.         } else {
  59.             values4.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  60.             values4.put(Phone.NUMBER, mEmployee.getMobile());
  61.             values4.put(Phone.TYPE, Phone.TYPE_WORK_MOBILE);
  62.         }
  63.         data.add(values4);
  64.         // 添加固定电话
  65.         ContentValues values5 = new ContentValues();
  66.         values5.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  67.         values5.put(Phone.NUMBER, mEmployee.getOfficeTel());
  68.         values5.put(Phone.TYPE, Phone.TYPE_WORK);
  69.         data.add(values5);
  70.         // 添加传真
  71.         ContentValues values6 = new ContentValues();
  72.         values6.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
  73.         values6.put(Phone.NUMBER, mEmployee.getFax());
  74.         values6.put(Phone.TYPE, Phone.TYPE_FAX_WORK);
  75.         data.add(values6);
  76.         // 添加地址 邮编
  77.         ContentValues values7 = new ContentValues();
  78.         values7.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
  79.         values7.put(StructuredPostal.FORMATTED_ADDRESS, mEmployee.getAddress());
  80.         values7.put(StructuredPostal.POSTCODE, mEmployee.getPostCode());
  81.         values7.put(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK);
  82.         data.add(values7);
  83.         // 添加头像
  84.         ContentValues values8 = new ContentValues();
  85.         values8.put(Data.MIMETYPE, Photo.CONTENT_ITEM_TYPE);
  86.         // if (mEmployee.getGender().equals(“2”))// 为女,保存女性默认头像
  87.         // values.put(Photo.PHOTO,
  88.         // getDrawableToByte(R.drawable.oa_contact_head_f));
  89.         // else
  90.         // 男
  91.         values8.put(Photo.PHOTO, getDrawableToByte(R.drawable.oa_contact_head_m));
  92.         data.add(values8);
  93.         intent.putParcelableArrayListExtra(Insert.DATA, data);
  94.         context.startActivity(intent);
  95.     }

标签