欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 男人天堂中文字幕 | 一级毛片观看 | 自拍偷拍中文字幕 | 免费看a | 精品国产网站 | 免费福利视频在线观看 | 日韩1区 | 日韩一区二区在线观看视频 | 四虎综合 | 亚洲精品久久久久综合中文字幕 | 人人爱人人做 | 日韩中文一区二区三区 | 99久久精品费精品国产一区二区 | 成人一级黄色大片 | 五月婷婷激情六月 | 排球少年第四季樱花动漫 | 欧美日韩在线一区 | 国产噜噜噜 | 久久免费视频在线 | 高清videosgratis欧美live | 亚洲高清视频在线观看 | 国产精品一区二区三区四区 | 欧美女人天堂 | 国产日韩在线视频 | 伊人狠狠 | 69av.com| 久久99视频精品 | 国产精品小黄鸭一区二区三区 | 精品在线 | 国产成人短视频 | 国产不卡在线 | 玖玖操 | 夜夜夜操操操 | 日韩大片在线 | 亚洲一区 中文字幕 | 91精品国产日韩91久久久久久360 | 日韩国产欧美视频 | 中国一级黄色片 | 青草青草久热精品视频在线网站 | 一级毛片欧美 | 一区二区高清 |