public static Intent prepareAddContactIntent(String displayName, String sipUri) { Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); intent.putExtra(Insert.NAME, displayName); if (sipUri != null && sipUri.startsWith("sip:")) { sipUri = sipUri.substring(4); } ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues sipAddressRow = new ContentValues(); sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE); sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri); data.add(sipAddressRow); intent.putParcelableArrayListExtra(Insert.DATA, data); return intent; }
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) { Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI); Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id); intent.setData(contactUri); ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues sipAddressRow = new ContentValues(); sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE); sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri); data.add(sipAddressRow); intent.putParcelableArrayListExtra(Insert.DATA, data); return intent; }
@Override public Intent getAddContactIntent(String displayName, String csipUri) { Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI); intent.setType(Contacts.CONTENT_ITEM_TYPE); if (!TextUtils.isEmpty(displayName)) { intent.putExtra(Insert.NAME, displayName); } if (!TextUtils.isEmpty(csipUri)) { ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues csipProto = new ContentValues(); csipProto.put(Data.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE); csipProto.put(CommonDataKinds.Im.PROTOCOL, CommonDataKinds.Im.PROTOCOL_CUSTOM); csipProto.put(CommonDataKinds.Im.CUSTOM_PROTOCOL, SipManager.PROTOCOL_CSIP); csipProto.put(CommonDataKinds.Im.DATA, SipUri.getCanonicalSipContact(csipUri, false)); data.add(csipProto); intent.putParcelableArrayListExtra(Insert.DATA, data); } return intent; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case id.menu_edit_profile: Intent intent = new Intent(getActivity(), ProfileEditActivity.class); startActivity(intent); break; case id.menu_add_contact: Intent add_contact_intent = new Intent(Insert.ACTION); add_contact_intent.setType(RawContacts.CONTENT_TYPE); startActivityForResult(add_contact_intent, TAG_ADD_CONTACT); break; case id.menu_about: Intent about_intent = new Intent(getActivity(), AboutActivity.class); startActivity(about_intent); break; } return super.onOptionsItemSelected(item); }
@Override public void onClick(View view) { operate_Manage_PopupWindow.dismiss(); switch (view.getId()) { case R.id.popup_key_manage_textView_save: Intent intent_save = new Intent(Intent.ACTION_INSERT); intent_save.setType("vnd.android.cursor.dir/person"); intent_save.setType("vnd.android.cursor.dir/contact"); intent_save.setType("vnd.android.cursor.dir/raw_contact"); // 添加姓名 intent_save.putExtra(Insert.NAME, realName); // 添加手机 intent_save.putExtra(Insert.PHONE_TYPE, Phone.TYPE_MOBILE); intent_save.putExtra(Insert.PHONE, tel); startActivity(intent_save); break; case R.id.popup_key_manage_textView_dial: Intent intent_dial = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + tel)); startActivity(intent_dial); break; } }
private void handleContact(VH_CONTACT holder, ChatItemDataModel item) { try { JSONObject jsonObject = new JSONObject(item.message); final String name = jsonObject.getString("name"); final String number = jsonObject.getString("number"); holder.mName.setText(name == null ? "" : name); holder.mNumber.setText(number == null ? "" : number); holder.mTime.setText(Utils.getTimeFromTimestamp(item.timestamp, false)); holder.mAddToContactButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType(Contacts.CONTENT_TYPE); intent.putExtra(Insert.NAME, name); intent.putExtra(Insert.PHONE, number); if (intent.resolveActivity(mContext.getPackageManager()) != null) { mContext.startActivity(intent); } else { Toast.makeText(mContext, R.string.cc_no_contact_app, Toast.LENGTH_SHORT).show(); } } }); } catch (JSONException e) { FirebaseCrash.log(e.getStackTrace().toString()); } holder.itemView.setContentDescription("contact"); }
public static void addToFacebookContact(Context mContext, ArrayList<String> contactDatas) { /** * ArrayList elements: * * 1. Name 2. Userid 3.Username */ Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT); i.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE); if (contactDatas.get(2) == null) { contactDatas.set(2, "Facebook name"); } ArrayList<ContentValues> data = new ArrayList<ContentValues>(); ContentValues row1 = new ContentValues(); row1.put(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE); row1.put(ContactsContract.Data.DATA1, contactDatas.get(2)); row1.put(ContactsContract.Data.DATA2, ContactsContract.CommonDataKinds.Im.TYPE_OTHER); row1.put(ContactsContract.Data.DATA5, ContactsContract.CommonDataKinds.Im.PROTOCOL_CUSTOM); row1.put(ContactsContract.Data.DATA6, "Facebook"); row1.put(ContactsContract.Data.DATA10, contactDatas.get(1)); data.add(row1); i.putExtra(Insert.NAME, contactDatas.get(0)); i.putParcelableArrayListExtra(ContactsContract.Intents.Insert.DATA, data); mContext.startActivity(i); }
@Override public Intent getShowOrCreateIntent( String email ) { Intent intent = criteria.getShowOrCreateIntent( email ); intent.putExtra( Insert.NAME, getDisplayName( email ) ); intent.putExtra( Insert.IM_PROTOCOL, Im.PROTOCOL_JABBER ); intent.putExtra( Insert.IM_HANDLE, email ); return intent; }