安卓日历

标签 android insert calendar exists

我正在尝试将项目放入日历中,但无法真正找到如何对其进行编码。这是我目前所拥有的,但它将它插入到主日历中。

    String calName; 
    String calId = null;
    String[] projection = new String[] { "_id", "name" };

    Uri calendars = Uri.parse("content://calendar/calendars");
    Cursor managedCursor = managedQuery(calendars, projection, null, null, null);
    ContentValues event = new ContentValues();

    event.put("calendar_id", calId);
    event.put("title", strTitle);
    event.put("description", strDescription);
    event.put("eventLocation", strLocation);
    event.put("dtstart", StartTime);
    event.put("dtend", EndTime);

    Uri eventsUri = Uri.parse("content://calendar/events");
    Uri calUri = getContentResolver().insert(eventsUri, event);

所以我的问题是:

  1. 如何创建自己的日历以将 Activity 放入

  2. 如何将我的 Activity 插入该日历(使用上面的代码或新代码)

  3. 如何检查事件是否已经存在

~~~更新:~~~

我想做的是我的用户将输入标题和日期,我的应用程序将采用该标题和日期,将它们放入数据库(到目前为止我所做的一切),现在我想获取标题和日期并将它们放入专门用于我的应用程序事件的特殊日历中。我需要做的第一件事是让应用程序创建一个新日历。比将事件插入到日历中,下面的代码可以帮助我做一些事情。还在玩它。比我想重新运行我的应用程序并检查事件是否存在。就这些。

最佳答案

首先,自 2.2 以来内容解析器发生了变化,我认为从 content://calendar/calendarscontent://com.android.calendar/calendars

要插入 Event ,检索 Event 检查此代码

https://github.com/Rabgs/AndroidLib_Google-Calendar/blob/master/src/net/mobiwide/agenda/google/GoogleAgenda.java

您将找到所需的一切以及如何跨平台处理内容解析器更改。

关于安卓日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6318507/

相关文章:

python - 使用 Python 生成一条 SQL 语句以一次将多行插入 MySQL 数据库

javascript - Google Apps 脚本 - createEvent 函数不创建日历事件

php/mysql : database of bank holidays and events like christmas, 复活节等

java - 如何调用其他方法的返回是其他方法的输入?

java - 如何将 .jar 依赖项包含到最终的 .aar 库文件中? (安卓工作室1.5)

android - 游标索引越界 “index 0 requested: with size 0”

android - Backendless multiuser flow - 切换当前用户

java - Android:将数据从 ViewPager2 和 TabLayout 管理的 fragment 发送到包含的 Activity

php - mysqli insert - 但只有在不重复的情况下

sql-server - 在SQL Server中将值插入表值参数