如何查询日历活动的提醒?未来的事件会出现,但他们的提醒却没有

时间:2013-02-26 06:57:32

标签: android android-contentprovider android-contentresolver android-calendar

当我查询Events.CONTENT_URI的内容解析器时,它会正确显示我未来的事件并且他们有警报。但是当我查询Reminders.CONTENT_URI时,它只显示已经发生的提醒。我想查找未来事件是否有提醒,并允许用户在需要时将其删除。我该怎么做呢?我在哪里可以找到这些信息?

此处仅显示已经发生的提醒

//Get all reminders
Cursor cursor = getContentResolver().query(
    Reminders.CONTENT_URI, null, null, null, null 
);

//None of my future events show here even though they have reminders
while (cursor.moveToNext())
{           
        Log.d(TAG,
                "Id: " + cursor.getInt(cursor.getColumnIndex(Reminders._ID)) +
                ", Minutes: " + cursor.getInt(cursor.getColumnIndex(Reminders.MINUTES)) +
                ", Method: " + cursor.getInt(cursor.getColumnIndex(Reminders.METHOD))
        );
}

这会显示所有未来事件(所有事件都有提醒,但它们未在提醒中显示

//Get all events
Cursor cursor = getContentResolver().query(
    Events.CONTENT_URI, null, null, null, null
);

while (cursor.moveToNext())
{           
     //This correctly shows the future events each have an alarm (hasAlarm = 1)
     Log.d(TAG, 
          cursor.getString(cursor.getColumnIndex(Events.TITLE)) + ","
          cursor.getInt(cursor.getColumnIndex(Events.HAS_ALARM))
     );
}

如何查找(以及更改)未来事件的提醒?

编辑:CalendarAlerts也不会显示未来事件的警报!未来事件未显示在CalendarAlerts.CONTENT_URI

1 个答案:

答案 0 :(得分:2)

您需要将eventid作为参数传递给您想要提醒的未来事件的查询 args = new String[] { Long.toString(mEventId) };并且还需要使用where private static final String REMINDERS_WHERE = Reminders.EVENT_ID + "=?";