介绍
今天就跟大家聊聊有关如何在Android应用中调用系统联系人界面,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
<强>一、添加联系人强>
Intent addIntent =, new 意图(Intent.ACTION_INSERT, Uri.withAppendedPath (Uri.parse(“内容://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、数量); 名称:,,,,,,addIntent.putExtra (numberForNewConstant android.provider.ContactsContract.Intents.Insert.PHONE也); 电话: ,,,,,startActivity (addIntent);
<强>二、添加到已有联系人强>
LogUtil.logI (“================btnAddToOladContact=====================?; ,,,,,Intent oldConstantIntent =, new 意图(Intent.ACTION_INSERT_OR_EDIT); ,,,,,oldConstantIntent.setType (ContactsContract.Contacts.CONTENT_ITEM_TYPE); ,,,,,oldConstantIntent.putExtra (numberForNewConstant ContactsContract.Intents.Insert.PHONE也); ,,,,,oldConstantIntent.putExtra (ContactsContract.Intents.Insert.PHONE_TYPE, 3); ,,,,,startActivity (oldConstantIntent); ,,,,,如果(oldConstantIntent.resolveActivity (getActivity () .getPackageManager ()), !=, null) { ,,,,,,,LogUtil.logI (“================btnAddToOladContact=========是的============?; ,,,,,,,startActivity (oldConstantIntent); ,,,,,} ,,,,,,,LogUtil.logI (“================btnAddToOladContact=========没有============?;
<强>三、编辑联系人强>
Intent editIntent =, new 意图(Intent.ACTION_EDIT, Uri.parse(“内容://com.android.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); ,,,,,,,,,,,,,,,}
看完上述内容,你们对如何在Android应用中调用系统联系人界面有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。