简体   繁体   English

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

[英]Android. How to call calendar intent to display things in month view?

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

I added permissions in the manifest file, but doesn't work. 我在清单文件中添加了权限,但是不起作用。

You're missing a few steps (like setting the time you want to view, for example), have a look at the documentation , that I'm copying here for reference : 您遗漏了一些步骤(例如,设置要查看的时间),请看一下文档 ,我将其复制在此处以供参考:

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

Unfortunately, I don't think forcing the calendar app in month view is at all possible. 不幸的是,我认为根本不可能在月视图中强制使用日历应用程序。 The above will open the calendar for the given time but if the user has set his calendar app in week view mode, there isn't much you can do about it. 上面的代码将打开给定时间的日历,但是如果用户将他的日历应用设置为周视图模式,那么您将无能为力。 I'd love to be proved wrong about that last bit ! 我很想证明那最后一点是错误的! :-) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM