Java Android:如何将ics文件发送到手机上的应用程序

Java Android:如何将ics文件发送到手机上的应用程序,java,android,calendar,icalendar,android-implicit-intent,Java,Android,Calendar,Icalendar,Android Implicit Intent,我正在活动中创建一个.ics文件。我想将创建的.ics文件发送到手机上的日历应用程序,以便该应用程序可以导入事件 以下是我的意图代码: `Intent intent = new Intent(Intent.ACTION_SEND); intent.addCategory(Intent.CATEGORY_APP_CALENDAR); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(icsfile));

我正在活动中创建一个.ics文件。我想将创建的.ics文件发送到手机上的日历应用程序,以便该应用程序可以导入事件

以下是我的意图代码:

`Intent intent = new Intent(Intent.ACTION_SEND);
        intent.addCategory(Intent.CATEGORY_APP_CALENDAR);
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(icsfile));
        startActivity(Intent.createChooser(intent, "How do you want to share?"));`    

不幸的是,选择器中没有显示日历应用程序。

至少谷歌日历不支持响应
操作\u发送

因此,请尝试:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(icsfile), "application/ics");
startActivity(intent);
(最终,切换到使用
FileProvider
,而不是
Uri.fromFile()
,因为对于
targetSdkVersion
为23或更高版本的应用程序,这在Android 7.0+上不起作用)