如何使用日历意图? [英] How to use Calendar Intent?

查看:55
本文介绍了如何使用日历意图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的应用程序启动日历,这样我就可以让用户将约会放在该日历上,然后让我的应用程序读取这些日历.

I am trying to Launch a calendar from my app, so I can let users put their appointments to it and then have my app read those.

我尝试了在这里找到的一段代码:

I tried the piece of code I found on here:

ComponentName cn; 
Intent i = new Intent();         
cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");
i.setComponent(cn);
startActivity(i);

并得到错误

07-07 21:05:33.944: ERROR/AndroidRuntime(1089):
    Caused by: android.content.ActivityNotFoundException: Unable to find explicit
    activity class {com.google.android.calendar/com.android.calendar.LaunchActivity};
    have you declared this activity in your AndroidManifest.xml?

我确实在我的android清单文件中声明了com.android.calendar.LaunchActivity,但它仍然无法正常工作...

I did declare the com.android.calendar.LaunchActivity to my android manifest file and it still isn't working...

我认为使用仿真器无法做到这一点吗?我正在Android 3.0(HoneyComb)中做到这一点.

I'd think this not doable using the emulator? I am doing this in Android 3.0 (HoneyComb).

推荐答案

来自Andriod文档的这对我有用:

This, from Andriod docs, worked for me:

long startMillis = System.currentTimeMillis();
Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
builder.appendPath("time");
ContentUris.appendId(builder, startMillis);
intent = new Intent(Intent.ACTION_VIEW).setData(builder.build());
startActivity(intent);

更多信息在这里: Android日历文档.

这篇关于如何使用日历意图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆