我需要在Android应用程序中获取所有联系人的所有事件。
任何人都可以帮我这个吗? 我需要把Uri放在下面..
Cursor events = getContentResolver().query(xxxx,null,ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId, null, null);
答案 0 :(得分: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));
}
}
}