ContentProvider示例-Calendar Provider
来源:互联网 发布:华讯网络与华三 编辑:程序博客网 时间:2024/06/09 21:52
The Calender Provider API can be used by applications and sync adapters.
Here are the rules for inserting a new event:
- You must include
CALENDAR_ID
andDTSTART
. - You must include an
EVENT_TIMEZONE
. To get a list of the system's installed time zone IDs, usegetAvailableIDs()
. Note that this rule does not apply if you're inserting an event through theINSERT
Intent, described in Using an intent to insert an event—in that scenario, a default time zone is supplied. - For non-recurring events, you must include
DTEND
. - For recurring events, you must include a
DURATION
in addition toRRULE
orRDATE
. Note that this rule does not apply if you're inserting an event through theINSERT
Intent, described in Using an intent to insert an event—in that scenario, you can use anRRULE
in conjunction withDTSTART
andDTEND
, and the Calendar application converts it to a duration automatically.
Calendar beginTime = Calendar.getInstance();beginTime.set(2012, 0, 19, 7, 30);Calendar endTime = Calendar.getInstance();endTime.set(2012, 0, 19, 8, 30);Intent intent = new Intent(Intent.ACTION_INSERT) .setData(Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) .putExtra(Events.TITLE, "Yoga") .putExtra(Events.DESCRIPTION, "Group class") .putExtra(Events.EVENT_LOCATION, "The gym") .putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY) .putExtra(Intent.EXTRA_EMAIL, "rowan@example.com,trevor@example.com");startActivity(intent);
static Uri asSyncAdapter(Uri uri, String account, String accountType) { return uri.buildUpon() .appendQueryParameter(android.provider.CalendarContract.CALLER_IS_SYNCADAPTER,"true") .appendQueryParameter(Calendars.ACCOUNT_NAME, account) .appendQueryParameter(Calendars.ACCOUNT_TYPE, accountType).build(); }
Here is an example that shows how to open the Calendar to a particular date:
// A date-time specified in milliseconds since the epoch.long startMillis;...Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();builder.appendPath("time");ContentUris.appendId(builder, startMillis);Intent intent = new Intent(Intent.ACTION_VIEW) .setData(builder.build());startActivity(intent);
Here is an example that shows how to open an event for viewing:
long eventID = 208;...Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);Intent intent = new Intent(Intent.ACTION_VIEW) .setData(uri);startActivity(intent);
Here is an example of an intent that sets a new title for a specified event and lets users edit the event in the Calendar.
long eventID = 208;Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, eventID);Intent intent = new Intent(Intent.ACTION_EDIT) .setData(uri) .putExtra(Events.TITLE, "My New Title");startActivity(intent);
0 0
- ContentProvider示例-Calendar Provider
- Calendar Provider
- Calendar Provider(中文版)
- Android Calendar Provider基础
- Android Calendar Provider总结
- 示例:Calendar
- Calendar示例
- ContentProvider示例
- ContentPRovider示例
- Content Provider之Calendar And Contact Provider
- Calendar Provider 日历数据存储
- Android API Guides---Calendar Provider
- Android Calendar Provider(日历事件)
- Content Provider(三) 自定义ContentProvider
- Calendar控件应用示例
- 其他对象(Calendar示例)
- Calendar(示例,出错代码)
- Calendar类示例
- perl - 设置html编码
- CSS样式优先权
- 多线程问题基本pv问题
- U-boot中控制台命令
- linux配置java环境变量(详细)
- ContentProvider示例-Calendar Provider
- redhat 的网络配置
- hdoj Numbers 5585 (水题)
- Contest1040 - 第三届“图灵杯”NEUQ-ACM程序设计大赛(个人赛) H: 橙子姐姐的梦 基数排序
- 利用BeautifulSoup和python处理xml
- nginx 基本配置
- Graphics
- hdoj Sum 5586 (模拟dp)
- android的定时任务