欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

如何保存聯系人

系統 2034 0

這兩天項目有個需求,可以對事務操作人進行 【新建聯系人】【保存到已有聯系人】【編輯聯系人(xxx)】.

總結一下,日后備用。先看一下效果:

如何保存聯系人 如何保存聯系人

一、【新建聯系人】主要是給系統發一個Intent

public void addContact() {
Intent intent = new Intent("android.intent.action.INSERT",
People.CONTENT_URI);
if (emailAdderss != null) {//將要增加的聯系人信息放到 exta data里
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, emailAdderss);
intent.putExtra(ContactsContract.Intents.Insert.NAME, creatorName);
}
startActivity(intent);
setResult(RESULT_FIRST_USER);
finish();

}

二、【保存到已有聯系人】.(備注: 選聯系人中之后,到編輯該聯系人,程序手動需要繼續調用系統功能

1、先調用系統的已有聯系人列表

Intent intent = new Intent("android.intent.action.PICK",
People.CONTENT_URI);
2、設置resultCodestartActivityForResult(intent,Constants.PICK_CONTACT);

3、編寫響應 resultCode 代碼,做出編輯響應。

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

switch (requestCode) {
case Constants.PICK_CONTACT:
if (resultCode == RESULT_OK) {
Uri contactData = data.getData();
String urlStr = contactData.getEncodedPath();
String[] idStrs = urlStr.split("/");
int id = Integer.parseInt(idStrs[2]);// 主要是獲得 選中人的 id 然后 進行編輯

if (Build.VERSION.SDK_INT == 4 || Build.VERSION.RELEASE.equals("1.6")) {// 發送編輯聯系人請求

// for sdk1.6
Intent intent_ = new Intent("android.intent.action.EDIT", Uri.parse("content://contacts/people/" + id));
intent_.putExtra(ContactsContract.Intents.Insert.EMAIL, emailAdderss);
startActivity(intent_);

} else {
Intent intent_ = new Intent("android.intent.action.EDIT", Uri.parse("content://com.android.contacts/raw_contacts/" + id));
intent_.putExtra(ContactsContract.Intents.Insert.EMAIL, emailAdderss);

startActivity(intent_);
}
finish();
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
break;
}

三:編輯以后聯系人

1、根據email獲得聯系人名稱

public String lookupContactNameByEmail(String email) {

String where=Email.DATA1+"=?";
Cursor cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, new String[]{ Email.CONTACT_ID}, where, new String[]{email}, null);
if(cursor.moveToNext()){
String contactWhere=Contacts._ID+"="+cursor.getInt(0);
cursor.close();
Cursor cursor2 = getContentResolver().query(Contacts.CONTENT_URI, new String[]{Contacts.DISPLAY_NAME}, contactWhere, null,null);
if(cursor2.moveToNext()){
String str = cursor2.getString(0);
return str;
}
}
return "unKnow";
}

2、發送編輯Action

public void editContact() {
Integer id = null;
Cursor cursor = getContactsByEmail();
if(cursor.getCount()>0){
cursor.moveToFirst();
id = cursor.getInt(cursor.getColumnIndex(Data.RAW_CONTACT_ID));
DebugUtils.v(TAG, emailAdderss+"===================================================+++"+id );
cursor.close();
if (Build.VERSION.SDK_INT == 4 || Build.VERSION.RELEASE.equals("1.6")) {

// for sdk1.6
Intent intent_ = new Intent("android.intent.action.EDIT", Uri.parse("content://contacts/people/" + id));

startActivity(intent_);

} else {
Intent intent_ = new Intent("android.intent.action.EDIT", Uri.parse("content://com.android.contacts/raw_contacts/" + id));
startActivity(intent_);
}

finish();
}


}

如何保存聯系人


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: www.75zzz.com| 日本三级韩国三级欧美三级 | 成人网在线免费观看 | 国产精品亚欧美一区二区三区 | 毛片搜索 | 99超级碰碰成人香蕉网 | 国内自拍视频在线看免费观看 | 欧美日本一区 | 三级高清| 亚洲午夜精品A片久久WWW软件 | 午夜资源 | 看中国国产一级毛片真人视频 | 久久精品视 | 九色亚洲 | 亚洲国产中文字幕 | 日韩中文字幕网 | 亚洲第一成网站 | 亚洲日本一区二区三区 | 91精品国产综合久久久久久 | 成人在线综合网 | 国产一级一级毛片 | 欧美aaaa视频 | 久草久视频 | 波多久久亚洲精品AV无码 | 在线视频不卡国产在线视频不卡 | 黄色免费视频观看 | 欧美精品在线一区二区三区 | 久久久久久国产精品免费免费 | 国产精彩视频 | 亚洲精品久久久久无码AV片软件 | 精品日韩在线 | 精品亚洲福利一区二区 | 成人无码T髙潮喷水A片小说 | 亚洲第一a亚洲 | 久久人精品 | 精品一区二区三区在线播放 | 日韩第一页| 性夜影院爽黄A爽免费动漫 日韩精品在线一区二区 | 国产毛片精品 | 国产日产亚洲欧美综合另类 | 亚洲久草 |