【发布时间】:2020-06-30 01:31:30
【问题描述】:
当用户在我的 android 应用程序中添加一个谷歌日历事件时,我希望它也应该反映在我的 android 日历应用程序和网络谷歌日历中?我怎样才能做到这一点?
【问题讨论】:
标签: android web events calendar
当用户在我的 android 应用程序中添加一个谷歌日历事件时,我希望它也应该反映在我的 android 日历应用程序和网络谷歌日历中?我怎样才能做到这一点?
【问题讨论】:
标签: android web events calendar
您可以使用 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>
【讨论】: