Android 把电话保存到现有联系人 已有联系人


  搜索了很长时间,想找个把电话保存到现有联系人的代码,就是打开选中的联系人编辑界面,然后自动添加电话,再手动保存,就跟手机上的一样,功夫不负有心人,终于给搜到了,很不容易啊,现分享如下,

 

 1 // 保存至现有联系人
 2     public void saveExist(String name, String phone) {
 3         Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
 4         intent.setType("vnd.android.cursor.item/person");
 5         intent.setType("vnd.android.cursor.item/contact");
 6         intent.setType("vnd.android.cursor.item/raw_contact");
 7     //    intent.putExtra(android.provider.ContactsContract.Intents.Insert.NAME, name);
 8         intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, phone);
 9         intent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE_TYPE, 3);
10         startActivity(intent);
11     }

  由于现有联系人已经有名称,故把修改联系人名称的代码注释掉。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM