Android系统。如何调用日历意图在月视图中显示内容?

时间:2014-01-21 16:56:01

标签: android android-intent view android-activity calendar

        Intent calIntent = new Intent(Intent.ACTION_VIEW);
        calIntent.setData(CalendarContract.Events.CONTENT_URI);
        startActivity(calIntent);

我在清单文件中添加了权限,但无效。

1 个答案:

答案 0 :(得分:1)

您错过了几个步骤(例如设置您要查看的时间),请查看documentation,我正在此处复制以供参考:

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

不幸的是,我认为在月视图中强制使用日历应用程序是不可能的。以上将打开给定时间的日历,但如果用户在周视图模式下设置了他的日历应用程序,则您无能为力。关于最后一点,我很想被证明是错的! : - )