android 应用组件[通用 Intent---添加日历事件] 五
2017-04-05 09:16
453 查看
如需向用户的日历添加新事件,请使用
URI。 然后您就可以使用下文介绍的 extra 指定事件的各类详细信息。
操作
示例 Intent:
public void addEvent(String title, String location, Calendar begin, Calendar 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);
}
}
示例 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>
ACTION_INSERT操作指定具有
Events.CONTENT_URI的数据
URI。 然后您就可以使用下文介绍的 extra 指定事件的各类详细信息。
操作
ACTION_INSERT数据 URI
Events.CONTENT_URIMIME 类型
"vnd.android.cursor.dir/event"Extra
EXTRA_EVENT_ALL_DAY一个布尔型值,指定此事件是否为全天事件。
EXTRA_EVENT_BEGIN_TIME事件的开始时间(从新纪年开始计算的毫秒数)。
EXTRA_EVENT_END_TIME事件的结束时间(从新纪年开始计算的毫秒数)。
TITLE事件标题。
DESCRIPTION事件说明。
EVENT_LOCATION事件地点。
EXTRA_EMAIL以逗号分隔的受邀者电子邮件地址列表。可使用
CalendarContract.EventsColumns类中定义的常量指定许多其他事件详细信息。
示例 Intent:
public void addEvent(String title, String location, Calendar begin, Calendar 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);
}
}
示例 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>
相关文章推荐
- android 应用组件[通用 Intent---联系人/人员应用] 九
- android 应用组件[通用 Intent---撰写带有可选附件的电子邮件] 十
- android 应用组件[通用 Intent---叫车] 十三
- android 应用组件[通用 Intent---基于搜索查询播放音乐] 十六
- android 应用组件[通用 Intent---发起通话] 十八
- android 应用组件[通用 Intent---设置] 二十
- android 应用组件[通用 Intent---拍摄照片或视频并将其返回] 六
- android 应用组件[通用 Intent---显示地图上的位置] 十四
- android 应用组件[通用 Intent---以静态图像模式启动相机应用] 七
- android 应用组件[通用 Intent---创建笔记] 十七
- android 应用组件[通用 Intent---加载网址] 二十二
- android 应用组件[通用 Intent---撰写带附件的短信/彩信] 二十一
- android 应用组件[通用 Intent---创建定时器] 三
- android 应用组件[通用 Intent---播放媒体文件] 十五
- android 应用组件[通用 Intent---以视频模式启动相机应用] 八
- android 应用组件[通用 Intent---打开特定类型的文件] 十二
- android 应用组件[通用 Intent---创建闹铃] 二
- android 应用组件[通用 Intent---显示所有闹铃] 四
- android 应用组件[通用 Intent---检索特定类型的文件] 十一
- android 应用组件[通用 Intent---搜索] 十九