0

我需要在我的 android 应用程序中获取所有联系人的所有事件。

谁可以帮我这个事?我需要为下面放置 Uri..

Cursor events = getContentResolver().query(xxxx,null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId, null, null);
4

1 回答 1

0

试试这个方法,应该可以的。做Log.d(tag, "Output here");测试你的输出,但它应该工作。它在这里。

public void getEvent(String contactId)
    {
        final String[] projection = new String[] {
                Event.CONTACT_ID,
                Event.START_DATE,
                //Event.TYPE,
                Event.LABEL
        };

        final String filter = Data.MIMETYPE + " = ? AND " + Data.CONTACT_ID + " = ? ";
        final String parameters[] = {Event.CONTENT_ITEM_TYPE, contactId};

        Cursor cursor =  context.getContentResolver().query(Data.CONTENT_URI, 
                    projection, 
                    filter, 
                    parameters,
                    null);

        if(cursor.moveToFirst())
        {
            for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext())
            {
                final String contact_id = cursor.getString(cursor.getColumnIndex(Event.CONTACT_ID));
                final String startDate = cursor.getString(cursor.getColumnIndex(Event.START_DATE));
                //final String type = cursor.getString(cursor.getColumnIndex(Event.TYPE));
                final String label = cursor.getString(cursor.getColumnIndex(Event.LABEL));
            }
        }

    }
于 2014-01-23T15:20:08.563 回答