Android 2.2的日历

Android 2.2的日历,android,calendar,Android,Calendar,我想从手机上的谷歌日历中检索事件。有好的样品吗?我不熟悉日历,需要一些帮助…这涉及内容提供商。具体来说,您正在查找为日历的ContentProvider找到的代码 这可能有助于您开始: 这涉及到内容提供者。具体来说,您正在查找为日历的ContentProvider找到的代码 这可能有助于您开始: 如果您只想访问本地日历数据库/URI,那么这些链接(对JoxTraex没有冒犯)就过于健壮了 Uri.Builder builder = Uri.parse("content://com.android

我想从手机上的谷歌日历中检索事件。有好的样品吗?我不熟悉日历,需要一些帮助…

这涉及内容提供商。具体来说,您正在查找为日历的ContentProvider找到的代码

这可能有助于您开始:


这涉及到内容提供者。具体来说,您正在查找为日历的ContentProvider找到的代码

这可能有助于您开始:


如果您只想访问本地日历数据库/URI,那么这些链接(对JoxTraex没有冒犯)就过于健壮了

Uri.Builder builder = Uri.parse("content://com.android.calendar/instance/when").buildUpon();
long currentTime = new Date().getTime();    //Get current time

ContentUris.appendId(builder, currentTime - DateUtils.WEEK_IN_MILLIS);
ContentUris.appendId(builder, currentTime + DateUtils.WEEK_IN_MILLIS);

Cursor eventCursor = contentResolver.query(builder.build(), new String[] { "title", "begin", "end", "allDay"}, "Calendars._id=" + calID, null, "startDay ASC, startMinute ASC"); 
现在你所要做的就是解析你的游标,你就可以得到前一周和下一周的事件

当然,您可以更改ContentUris.appendId中的信息。。。做任何你喜欢的事情,并得到有趣的结果。对于我正在开发的应用程序,我让用户设置一个变量,该变量将指示返回事件的时间间隔


一旦有了大量的4.0+设备,那么所有这些都将变得简单得多。

如果您只想访问本地日历数据库/URI,那么这些链接(无意冒犯JoxTraex)就过于健壮了

Uri.Builder builder = Uri.parse("content://com.android.calendar/instance/when").buildUpon();
long currentTime = new Date().getTime();    //Get current time

ContentUris.appendId(builder, currentTime - DateUtils.WEEK_IN_MILLIS);
ContentUris.appendId(builder, currentTime + DateUtils.WEEK_IN_MILLIS);

Cursor eventCursor = contentResolver.query(builder.build(), new String[] { "title", "begin", "end", "allDay"}, "Calendars._id=" + calID, null, "startDay ASC, startMinute ASC"); 
现在你所要做的就是解析你的游标,你就可以得到前一周和下一周的事件

当然,您可以更改ContentUris.appendId中的信息。。。做任何你喜欢的事情,并得到有趣的结果。对于我正在开发的应用程序,我让用户设置一个变量,该变量将指示返回事件的时间间隔


一旦有了大量的4.0+设备,那么所有这些都会简单得多。

它应该遵循相同的风格。。试试看,应该是同一种款式。。试试看。