How can I get contact events synchronized with Google contacts without a year?

I use the code below to get the cursor for events and contacts, and it works great for events with the specified year. Unfortunately, events when only the day and month are specified are not returned by this request.

I set these dates in Google Contacts for some birthdays of the contact, and I wonder if I need to use RawContacts instead of ContactsContract to get these values?

Refresh . It appears that data entered into the phone without using a year is retrieved. Only events added through http://www.google.com/contacts that are not retrieved. I see these events in the Contacts application, although - it appears as something like --05-23 .

 String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, Event.CONTACT_ID, Event.START_DATE, Event.TYPE }; Cursor c = mContext.getContentResolver().query( ContactsContract.Data.CONTENT_URI, projection, ContactsContract.Data.MIMETYPE + "= ?", new String[] { Event.CONTENT_ITEM_TYPE }, Event.START_DATE); c.moveToFirst(); int nameIndex = c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME); int dateIndex = c.getColumnIndex(Event.START_DATE); String name, date; while (c.moveToNext()) { name = c.getString(nameIndex); date = c.getString(dateIndex); Log.d(TAG, "Event for " + name + " is " + date); } c.close(); 
+7
source share
2 answers

I work on Nexus S (2.3.4) and I used your exact code and I print out all the contacts, including those who don't have a year.

 07-19 17:08:36.847: DEBUG/test(24646): Event for Warren Upton is --12-01 07-19 17:08:36.851: DEBUG/test(24646): Event for Marion Atkins is 1934-11-24 

Can you give more details on how to reproduce the problem?

0
source

I assume that events without any year do not have Event.START_DATE set (since by definition the date will be day / month / year). If you remove it from projection and sorting, will they be restored?

0
source

All Articles