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)系人,編輯和修改),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android學(xué)習(xí)筆記之應(yīng)用單元測(cè)試實(shí)例分析
這篇文章主要介紹了Android學(xué)習(xí)筆記之應(yīng)用單元測(cè)試,結(jié)合實(shí)例形式較為詳細(xì)的分析了Android單元測(cè)試的實(shí)現(xiàn)原理與具體步驟,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-11-11
Flutter持久化存儲(chǔ)之?dāng)?shù)據(jù)庫存儲(chǔ)(sqflite)詳解
這篇文章主要給大家介紹了關(guān)于Flutter持久化存儲(chǔ)之?dāng)?shù)據(jù)庫存儲(chǔ)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
Android 開發(fā)之dataBinding與ListView及事件
這篇文章主要介紹了Android 開發(fā)之dataBinding與ListView及事件的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-10-10
android短信管理器SmsManager實(shí)例詳解
這篇文章主要為大家詳細(xì)介紹了android短信管理器SmsManager實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11
詳解Android Activity之間切換傳遞數(shù)據(jù)的方法
這篇文章主要介紹了詳解Android Activity之間切換傳遞數(shù)據(jù)的方法 的相關(guān)資料,需要的朋友可以參考下2016-04-04
Android自定義view實(shí)現(xiàn)電影票在線選座功能
這篇文章主要為大家詳細(xì)介紹了Android自定義view實(shí)現(xiàn)選座功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
Android實(shí)現(xiàn)跑馬燈效果的代碼詳解
Android中實(shí)現(xiàn)跑馬燈效果有多種方式,本文給大家介紹了Android實(shí)現(xiàn)跑馬燈效果的簡單示例,對(duì)大家的學(xué)習(xí)或工作有一定的幫助,感興趣的朋友可以參考下2018-05-05
Android自定義View之簡約風(fēng)歌詞控件實(shí)戰(zhàn)指南
一些接觸Android不久的朋友對(duì)自定義View都有一絲畏懼感,總感覺這是一個(gè)比較高級(jí)的技術(shù),但其實(shí)自定義View并不復(fù)雜,有時(shí)候只需要簡單幾行代碼就可以完成了,這篇文章主要給大家介紹了關(guān)于Android自定義View之簡約風(fēng)歌詞控件的相關(guān)資料,需要的朋友可以參考下2021-07-07

