Android 調(diào)用系統(tǒng)聯(lián)系人界面(添加聯(lián)系人,添加已有聯(lián)系人,編輯和修改)
一、添加聯(lián)系人
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);
二、添加到已有聯(lián)系人
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============");
三、編輯聯(lián)系人
Intent editIntent = new Intent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+cb.getContactId()));
startActivity(editIntent);
四、刪除聯(lián)系人
//*************刪除聯(lián)系人******************
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 調(diào)用系統(tǒng)聯(lián)系人界面(添加聯(lián)系人,添加已有聯(lián)系人,編輯和修改),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
Android學(xué)習(xí)筆記之應(yīng)用單元測試實例分析
這篇文章主要介紹了Android學(xué)習(xí)筆記之應(yīng)用單元測試,結(jié)合實例形式較為詳細(xì)的分析了Android單元測試的實現(xiàn)原理與具體步驟,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11
Flutter持久化存儲之?dāng)?shù)據(jù)庫存儲(sqflite)詳解
這篇文章主要給大家介紹了關(guān)于Flutter持久化存儲之?dāng)?shù)據(jù)庫存儲的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
Android 開發(fā)之dataBinding與ListView及事件
這篇文章主要介紹了Android 開發(fā)之dataBinding與ListView及事件的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-10-10
詳解Android Activity之間切換傳遞數(shù)據(jù)的方法
這篇文章主要介紹了詳解Android Activity之間切換傳遞數(shù)據(jù)的方法 的相關(guān)資料,需要的朋友可以參考下2016-04-04
Android自定義view實現(xiàn)電影票在線選座功能
這篇文章主要為大家詳細(xì)介紹了Android自定義view實現(xiàn)選座功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
Android自定義View之簡約風(fēng)歌詞控件實戰(zhàn)指南
一些接觸Android不久的朋友對自定義View都有一絲畏懼感,總感覺這是一個比較高級的技術(shù),但其實自定義View并不復(fù)雜,有時候只需要簡單幾行代碼就可以完成了,這篇文章主要給大家介紹了關(guān)于Android自定義View之簡約風(fēng)歌詞控件的相關(guān)資料,需要的朋友可以參考下2021-07-07

