我正在尝试做三件事。根据首选项中的选择,我想要打开已安装的日历应用程序,在已安装的日历中显示事件详细信息,或使用所需的已安装日历应用程序创建新事件。用户应该能够决定从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用于创建新事件。
我没有任何线索,为什么Jorte没有出现。我认为这也会发生在其他日历应用中。
如何在不读取设备上所有已安装的应用程序的情况下显示op Jorte(以及其他应用程序),并在日历应用程序上过滤以让用户在首选项内决定但在内置对话框中。
提前致谢!
答案 0 :(得分:1)
我没有任何线索,为什么Jorte没有出现。
因为它是日历应用,而不是Google日历前端。您的其他两个Intent
配置应仅由使用CalendarContract
存储其事件的应用程序来履行。 Jorte可能没有,因为它的Play商店描述表明“它可以与Google日历同步”(强调我的),表明它并不是一直存储在Google日历中的事件。并非要求所有日历应用都将其数据存储在CalendarContract
。
我认为这也会发生在其他日历应用中。
任何使用自己的数据存储的日历应用都应该像Jorte的行为一样。
如何显示op Jorte(以及其他人)
根据定义,您无法让任意日历应用支持您的第二个Intent
配置。这是为了查看特定的Google日历条目,并非每个日历应用都会将其活动存储在Google日历中。