Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何从日历中获取所有事件?_Android_Calendar - Fatal编程技术网

Android 如何从日历中获取所有事件?

Android 如何从日历中获取所有事件?,android,calendar,Android,Calendar,嗨,我可以使用此代码获取事件 cur = null; cr = getContentResolver(); // Construct the query with the desired date range. Uri.Builder builder = Instances.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, 0); ContentUris.appendId(builder,

嗨,我可以使用此代码获取事件

cur = null;
    cr = getContentResolver();


    // Construct the query with the desired date range.
    Uri.Builder builder = Instances.CONTENT_URI.buildUpon();

    ContentUris.appendId(builder, 0);
    ContentUris.appendId(builder, endMillis);


    // Submit the query
    cur =  cr.query(builder.build(), 
        INSTANCE_PROJECTION, 
        null, 
        null, 
        null);
但是正如你所看到的,我只能得到给定持续时间内的事件,但是我需要所有的事件(没有任何时间规范排除重复事件),这是可能的吗?怎么做? 请帮帮我

cur =  cr.query(Uri.parse("content://com.android.calendar/events"), 
        INSTANCE_PROJECTION, 
        null, 
        null, 
        null);
它给出了错误java.lang.IllegalArgumentException:

请尝试以下代码

公共类实用程序{
公共静态ArrayList nameOfEvent=新ArrayList();
公共静态ArrayList startDates=新ArrayList();
public static ArrayList endDates=new ArrayList();
public static ArrayList descriptions=new ArrayList();
公共静态ArrayList readCalendarEvent(上下文){
Cursor Cursor=context.getContentResolver()
.查询(
解析content://com.android.calendar/events"),
新字符串[]{“日历id”、“标题”、“说明”,
“dtstart”、“dtend”、“eventLocation”},空,
空,空);
cursor.moveToFirst();
//获取日历名称
字符串CNames[]=新字符串[cursor.getCount()];
//获取日历id
name of event.clear();
开始日期。清除();
endDates.clear();
descriptions.clear();
对于(int i=0;i
你也可以检查这个


看看这个如何使用日历获取参与者列表