【问题标题】:How to Add Google Calendar Event in your Android App?如何在您的 Android 应用中添加 Google 日历活动?
【发布时间】:2020-06-30 01:31:30
【问题描述】:

当用户在我的 android 应用程序中添加一个谷歌日历事件时,我希望它也应该反映在我的 android 日历应用程序和网络谷歌日历中?我怎样才能做到这一点?

【问题讨论】:

    标签: android web events calendar


    【解决方案1】:

    您可以使用 Intent 将事件添加到 Google 日历,如 docs 中所述

    示例意图:

    public void addEvent(String title, String location, long begin, long end) {
    Intent intent = new Intent(Intent.ACTION_INSERT)
            .setData(Events.CONTENT_URI)
            .putExtra(Events.TITLE, title)
            .putExtra(Events.EVENT_LOCATION, location)
            .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, begin)
            .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end);
      if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
      }
    }
    

    意图过滤器示例:

    <activity ...>
      <intent-filter>
        <action android:name="android.intent.action.INSERT" />
        <data android:mimeType="vnd.android.cursor.dir/event" />
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>
    </activity>
    

    【讨论】:

    • 我想要这个在后台。有可能吗?
    • 不,这是一个意图,因此用户将预先填充数据并自己添加事件。如果您需要在 bg 中完成此操作,那么 Calendar Content Provider 是您的最佳选择。
    • 我正在使用日历内容提供商将事件添加到我的 android 设备日历中,但未添加到谷歌日历中。
    • 你能帮我如何在谷歌日历中添加活动吗?我想要这里的活动calendar.google.com/calendar/r/day
    • 我明白了,所以该活动没有出现在 Google 日历应用中?您确定这不仅仅是 Google 日历 UI 中的过滤问题吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 1970-01-01
    • 2014-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多