Android有意打开任何日历应用程序(4.2.2及更高版本)

Android有意打开任何日历应用程序(4.2.2及更高版本),android,android-intent,calendar,Android,Android Intent,Calendar,我试着做三件事。根据首选项中的选择,我想打开已安装的日历应用程序,在已安装的日历中显示事件详细信息,或者使用所需的已安装日历应用程序创建新事件。用户应该能够通过android框架中的决策对话框决定使用什么应用程序 出于测试目的,我在谷歌日历应用程序中安装了aCalendar和Jorte。 目前只有“创建新事件”列出了执行此操作的所有3个应用程序 Intent intent = null; intent = new Intent(Intent.ACTION_EDIT); intent.setTyp

我试着做三件事。根据首选项中的选择,我想打开已安装的日历应用程序,在已安装的日历中显示事件详细信息,或者使用所需的已安装日历应用程序创建新事件。用户应该能够通过android框架中的决策对话框决定使用什么应用程序

出于测试目的,我在谷歌日历应用程序中安装了aCalendar和Jorte。 目前只有“创建新事件”列出了执行此操作的所有3个应用程序

Intent intent = null;
intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
使用该操作仅打开日历或日历详细信息时,选择对话框中仅显示aCalendar和google日历。两个都很好

这是我用来创建意图的完整方法:

private Intent createCalendarIntent()
{
    long startMillis = System.currentTimeMillis();
    Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon();
    builder.appendPath("time");
    ContentUris.appendId(builder, startMillis);
    Intent intent = null;

    Uri uri = ContentUris.withAppendedId(Events.CONTENT_URI, 
                                         calHandle.getEventID(0));          

    switch(getPreferenceIntentAction())
    {
        case 1: intent = new Intent(Intent.ACTION_VIEW);
                            intent.setType("vnd.android.cursor.item/event");
                            intent.setData(builder.build());
            break;
        case 2: intent = new Intent(Intent.ACTION_VIEW);
                            intent.setType("vnd.android.cursor.item/event");
                            intent.setData(uri);
            break;
        case 3: intent = new Intent(Intent.ACTION_EDIT);
                            intent.setType("vnd.android.cursor.item/event");
            break;
            default:
                break;
    }
案例1只是在实际的一周打开日历,案例2是显示事件细节,案例3是创建一个新事件

我不知道乔特为什么不来。我想这也会发生在其他日历应用程序上

如何才能显示op Jorte(以及其他内容),而不读取设备上所有已安装的应用程序,并在日历应用程序上进行筛选,让用户在首选项中但在内置对话框中进行决定

提前谢谢

我不知道乔特为什么不来

因为它是一个日历应用程序,而不是谷歌日历前端。您的另外两个
Intent
配置应该仅由使用
CalendarContract
存储其事件的应用程序执行。Jorte可能不会,因为它的Play Store描述表明“它可以与Google日历同步”(emphasis mine),这表明它不会一直在Google日历中存储事件。不要求所有日历应用程序都将其数据存储在
CalendarContract

我想这也会发生在其他日历应用程序上

任何使用自己数据存储的日历应用程序都应该像Jorte那样运行

怎么可能展示op Jorte(以及其他人)呢

根据定义,您不可能让任意日历应用程序支持您的第二个
Intent
配置。这是为了查看特定的谷歌日历条目,并不是每个日历应用程序都会将其事件存储在谷歌日历中