contactscontract

Android: set contact photo with ContactsContract insert intent

余生颓废 提交于 2019-12-06 13:25:41
I am using ContactsContract to insert a new contact by sending the user to a "New contact" intent. The code I am using is: Intent i = new Intent(Intent.ACTION_INSERT); i.setType(Contacts.CONTENT_TYPE); i.putExtra(Insert.NAME, "Some Contact Name"); i.putExtra(Insert.EMAIL, "address@email.com"); i.putExtra(Insert.PHONE, "123-456-7890"); startActivity(i); However, I need to also somehow pass in a locally stored photo (in res/drawable) to show up on this "New contact" intent. I was hoping that there would be an easy way to do this, like i.putExtra(Insert.PHOTO, uri_to_photo); but that obviously

Load a contact's picture into a listview instead of the default?

会有一股神秘感。 提交于 2019-12-06 07:15:33
I created a listview containing my contacts... tab_contact_list.xml , contains the listview: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ListView android:id="@+id/tab_contact_list" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </LinearLayout> listview_detail_tab_contact_list.xml , details rows of listview: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns

Android API 8 , 10 ContactsContract.Data.HAS_PHONE_NUMBER no such column

久未见 提交于 2019-12-06 06:20:06
问题 The below query runs fine on my device (API 15). It does not work in my emulator running API 8 or API 10. Here is the query: Cursor contactsCur = getContentResolver().query( ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data._ID, ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Organization.COMPANY, ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.Data.LOOKUP_KEY, ContactsContract.CommonDataKinds.Phone

How to get contacts with which the user talks often?

感情迁移 提交于 2019-12-06 03:33:40
问题 Is it possible using ContactsContract to get contacts with which the user talks often? I know I can use the CallLog ContentProvider and try to figure that out, but I wanted to know if there is already a way to do it. 回答1: The number of times a contact has been contacted ContactsContract.Contacts.times_contacted static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.STARRED,

Insert RawContact with a specific contactid

◇◆丶佛笑我妖孽 提交于 2019-12-06 01:42:23
I am trying to create a rawcontact in android that has a specific contact id, so it is linked to other rawcontacts with the same contactid (not rawcontactid). The problem is I am unable to insert the Contact_ID into the ContentProviderOpertations. Using the following code return "Insert failed" ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); int id = (int) contactId; String condition = Data.RAW_CONTACT_ID + "=?"; String[] parameters = { "" + id }; try { String accountName = account.name; String accountType = account.type; ops.add(ContentProviderOperation

How to add structured data to a new contact Intent

陌路散爱 提交于 2019-12-05 21:33:59
问题 I need to support Android 2.1 and up. Google posted an example of how to use the ContactsContract, but some of it used things that are available starting with API level 11, so I need to improvise, but I'm stuck. So, far I have this: String firstName = contactProperties.get("firstName"); String lastName = contactProperties.get("lastName"); String phone = contactProperties.get("phone"); String email = contactProperties.get("email"); String company = contactProperties.get("company"); String

Android : Adding Notes to Existing Contacts

守給你的承諾、 提交于 2019-12-05 12:38:46
I'm trying to use the ContactsContract api to add some notes to my contacts. I'm not sure I fully understand the various contact IDs and Raw Contact IDs. My problem seems pretty similar to what is discussed here . I want to : 1. Find a specific contact. 2. When found, insert specific notes I'm doing it in the following way: Cursor contacts = getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, null, null, null); while(contacts.moveToNext()){ Log.d("TC", "Found : " + name); int rid = contacts.getColumnIndex(ContactsContract.Data.RAW_CONTACT_ID); int rawContactID = contacts.getInt

Displaying contacts only with phone numbers using ACTION_PICK intent in Android device

你说的曾经没有我的故事 提交于 2019-12-05 04:04:38
My goal is to only display contacts with phone number to user and let user select few contacts which I want to store locally. I have used various options in place of ContactsContract.Contacts.CONTENT_URI in below method. But I am getting lot many of the contacts (many are junk with only email ids) displayed. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.contact_selector); ((Button)findViewById(R.id.btnphonecontactlist)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method

Android API 8 , 10 ContactsContract.Data.HAS_PHONE_NUMBER no such column

折月煮酒 提交于 2019-12-04 11:06:57
The below query runs fine on my device (API 15). It does not work in my emulator running API 8 or API 10. Here is the query: Cursor contactsCur = getContentResolver().query( ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.Data._ID, ContactsContract.Data.CONTACT_ID, ContactsContract.Data.DISPLAY_NAME, ContactsContract.CommonDataKinds.Organization.COMPANY, ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.Data.LOOKUP_KEY, ContactsContract.CommonDataKinds.Phone.NUMBER, Contacts.Data.MIMETYPE, ContactsContract.CommonDataKinds.Phone.MIMETYPE, ContactsContract

How to create a contact programmatically [duplicate]

风流意气都作罢 提交于 2019-12-04 08:42:43
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to add new contacts in android public boolean createContact(String name, String number, String email) { boolean success = true; try { ContentValues contentValues = new ContentValues(); ContentResolver contentResolver = getContentResolver(); contentValues.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); contentValues.put(Phone.NUMBER, "123254"); Uri uri = contentResolver.insert(android.provider.ContactsContract