android - 检查日历事件是否正在进行

标签 android calendar

我需要检查当前是否有“忙”的日历事件。

String[] projection = new String[] { BaseColumns._ID};
String selection = CalendarContract.Events.DTSTART + " <= ? AND "
        + CalendarContract.Events.DTEND + ">= ? AND "
        + CalendarContract.Events.AVAILABILITY + "=="
        + CalendarContract.Events.AVAILABILITY_BUSY;

Cursor cur = ctx.getContentResolver().query(CalendarContract.Events.CONTENT_URI,
        projection,
        selection,
        new String[] {String.valueOf(System.currentTimeMillis()),
        String.valueOf(System.currentTimeMillis())},
        null);

这段代码工作正常,但不适用于重复发生的事件。 我该如何解决这个问题?

最佳答案

我认为您需要做的就是切换您从中读取的表格,see here .

CalendarContract.Instances 应提供所有事件,包括重复事件

This table holds the start and end time for each occurrence of an event. Each row in this table represents a single event occurrence. For one-time events there is a 1:1 mapping of instances to events. For recurring events, multiple rows are automatically generated that correspond to multiple occurrences of that event.

关于android - 检查日历事件是否正在进行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48356470/

相关文章:

Android Studio (Kotlin) 如何将 StringArray 转换为 MutableList

java - Android教程切换第一种情况方法无法访问

c# - Lotus Notes 客户端中的日历项目正在另存为草稿

mysql - 在不使用日历表的情况下从非每日时间序列创建每日报告

java - 如何计算两次之间的差异

java - 如何在一个字符串中存储多个单词而不替换java中的旧单词

android - 数据集更改后如何默认防止 gridview 滚动

php - Ical VALARM 未注册

php - 从数据库创建的动态 ical 不起作用

android - API key 无效的 Firebase 身份验证