软件编程
位置:首页>> 软件编程>> Android编程>> Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改)

Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改)

作者:三世铜棺  发布时间:2023-12-10 17:08:08 

标签:android,联系人,界面

一、添加联系人


Intent addIntent = new Intent(Intent.ACTION_INSERT,Uri.withAppendedPath(Uri.parse("content://com.android.contacts"), "contacts"));
     addIntent.setType("vnd.android.cursor.dir/person");
     addIntent.setType("vnd.android.cursor.dir/contact");
     addIntent.setType("vnd.android.cursor.dir/raw_contact");
addIntent.putExtra(ContactsContract.Intents.Insert.NAME,number);
名称:      addIntent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, numberForNewConstant);
电话:
     startActivity(addIntent);

二、添加到已有联系人


LogUtil.logI("================btnAddToOladContact=====================");
     Intent oldConstantIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
     oldConstantIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
     oldConstantIntent.putExtra(ContactsContract.Intents.Insert.PHONE, numberForNewConstant);
     oldConstantIntent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, 3);
     startActivity(oldConstantIntent);
     if(oldConstantIntent.resolveActivity(getActivity().getPackageManager()) != null){
       LogUtil.logI("================btnAddToOladContact=========yes============");
       startActivity(oldConstantIntent);
     }else
       LogUtil.logI("================btnAddToOladContact=========no============");

三、编辑联系人


Intent editIntent = new Intent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+cb.getContactId()));
           startActivity(editIntent);

四、删除联系人


//*************删除联系人******************
               Uri deleteUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, cb.getContactId());
               Uri lookupUri = ContactsContract.Contacts.getLookupUri(ContactsDetailActivity.this.getContentResolver(), deleteUri);
               if (lookupUri != Uri.EMPTY) {
                 int del = ContactsDetailActivity.this.getContentResolver().delete(deleteUri, null, null);
                 LogUtil.logI("==========popupMenu============del:"+del);
               }

以上所述是小编给大家介绍的Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改)网站的支持!

来源:http://blog.csdn.net/mls1454001840/article/details/60764351

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com