在最新的android 4.0中,在日历方面新增加了相关的API,可以操作了,简单小结下.
1 创建一个日历的intent
Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event");
startActivity(calIntent);
2 设置日历的具体信息
Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event");
calIntent.putExtra(Events.TITLE, "My House Party");
calIntent.putExtra(Events.EVENT_LOCATION, "My Beach House"); calIntent.putExtra(Events.DESCRIPTION, "A Pig Roast on the Beach"); startActivity(calIntent);
3 设置日历事件提醒的具体时间
Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event");
calIntent.putExtra(Events.TITLE, "My House Party");
calIntent.putExtra(Events.EVENT_LOCATION, "My Beach House"); calIntent.putExtra(Events.DESCRIPTION, "A Pig Roast on the Beach");
GregorianCalendar calDate = new GregorianCalendar(2012, 7, 15); calIntent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true); calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis()); calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
calDate.getTimeInMillis());
startActivity(calIntent);
可以看到,可以设置事件是在某个时间点开始和结束的
4 calIntent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); calIntent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
calIntent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE); //设置只能私人看到事件
calIntent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);
//设置其他事件不能覆盖它
5 设置事件定期提醒
calIntent.putExtra(Events.RRULE, “FREQ=WEEKLY;COUNT=10;WKST=SU;BYDAY=TU,TH”);
这个规则参考RFC 5544 ,比如上面是说每个星期二,星期四执行,总共执行10次,即5周
android 4中新增的日历处理相关API
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
android 日历
引用:://.eoeandroid.com/thread-83969-1-1.htmlprivate void setTime(){ StringBuilder buf = new StringBuilder(); CalendarUtil cu = new CalendarUtil(); String chineseMonth = cu.getChineseMonth(Integer.parseInt(getCurrentDate("yyyy")), Integer.parseInt(getCurrentDate("MM")), ...
手机开发--------android sed html 当前日期 android -
电脑控制android手机神器,scrcpy
我同事有一个华为手机,手机里内置了NFC,然后把手机靠近下电脑,当然的,一定需要是华为笔记本,然后电脑就弹出一个界面,控制手机的界面,这个功能非常好,加上NFC的功能,体验也非常不错。最...
app 嵌入式 bootloader 网络 android -
Android开发学习笔记:手机震动控制浅析
Android系统中Vibrator对象负责对手机震动的处理,具体的实现方法:
移动开发 休闲 Android 震动 Vibrator -
android:日历视图的实现
参考链接
android java