android呼叫google calendar的方法

google calendar有两个版本以Froyo版作为分界
Froyo版之前的版本

i.setClassName("com.android.calendar", "com.android.calendar.LaunchActivity");

Froyo版之后的版本

i.setClassName("com.google.android.calendar", "com.android.calendar.LaunchActivity");

另外一种方法不呼叫具体的class,目前测试只在4.0版本以后可用
参考网址:http://developer.android.com/guide/topics/providers/calendar-provider.html

// 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);

如果要呼叫google canlendar的编辑页面的话

//all version of android
 Intent i = new Intent();

 // mimeType will popup the chooser any  for any implementing application (e.g. the built in calendar or applications such as "Business calendar"
 i.setType("vnd.android.cursor.item/event");

 // the time the event should start in millis. This example uses now as the start time and ends in 1 hour
 i.putExtra("beginTime", new Date().getTime());
 i.putExtra("endTime", new Date().getTime() + DateUtils.HOUR_IN_MILLIS);

 // the action
 i.setAction(Intent.ACTION_EDIT);
 startActivity(i);
posted @ 2012-08-15 14:45  日光之下无新事  阅读(706)  评论(0编辑  收藏  举报