【问题标题】:Android Google Calendar "Unable to launch event"Android Google 日历“无法启动活动”
【发布时间】:2016-03-10 13:57:52
【问题描述】:

案例 1 我在 Amazon AWS 上托管了一个日历事件 iCal .ics 文件,并且该文件的 HTTP URL 集成在我的 Android 应用程序中。

Here is the file

当用户点击 URL 时,会显示一个带有以下选项的意图选择器:

  • 日历应用
  • 用于下载文件的浏览器

当我选择 Google 日历时,它给我一个错误提示“无法启动活动”

当我选择 Chrome 时,文件会被下载,当用户点击下载的文件时,它会给出同样的错误“无法启动事件”

以下是使用桌面 chrome http 客户端 Postman 下载文件时的响应标头

Accept-Ranges → bytes
Content-Length → 959
Content-Type → application/octet-stream
Date → Thu, 10 Mar 2016 13:45:10 GMT
ETag → "5d48719213395a28e09e8adf01f6ce83"
Last-Modified → Wed, 09 Mar 2016 15:24:22 GMT
Server → AmazonS3
x-amz-id-2 → XXXXXXXXXXXXXXXXXXXXXXXXX
x-amz-request-id → XXXXXXXXXXXXXXXXXXX

案例 2 为了进行实验,我在本地 Apache 服务器上编写了一个简单的 PHP 脚本来下载相同的文件,而不是直接从 HTTP URL 访问文件

PHP 代码

<?php
$file = $_GET['file'];
if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile($file);
        exit;
    }
?>

文件下载成功,然后

  • 点击下载的文件
  • 从意图选择器中选择了 Google 日历
  • 事件已成功添加到谷歌日历中

以下是使用 PHP 脚本时的响应头

Cache-Control → must-revalidate, post-check=0, pre-check=0
Connection → Keep-Alive
Content-Description → File Transfer
Content-Disposition → attachment; filename=World_Television_Premiere_of_House_Of_Cards_March_1213_5pm_on_Zee_Cafe.ics
Content-Length → 959
Content-Transfer-Encoding → binary
Content-Type → application/octet-stream
Date → Thu, 10 Mar 2016 07:27:15 GMT
Expires → 0
Keep-Alive → timeout=5, max=100
Pragma → public
Server → Apache/2.4.7 (Ubuntu)
X-Powered-By → PHP/5.5.9-1ubuntu4.14

任何人都可以帮助理解为什么事件没有保存或适用于案例 1 吗?

提前致谢。 请帮忙。

编辑

Android 设备:Nexus 6 (6.0.1)

谷歌日历应用:5.3.6-115544951-release

【问题讨论】:

  • 流式传输它仍然有效吗?因为那对我不起作用。仅当我从 gmail 中打开 ICS 文件时,它才对我有用。尝试打开 ICS 的任何其他方式都会出现“无法启动事件”错误。你有一个我可以测试的对你有用的 URL 吗?谢谢!

标签: android google-chrome http-headers google-calendar-api icalendar


【解决方案1】:

目前 - 这是 2016 年 4 月 27 日 - 提供的文件在我的 Android 版 Google 日历 v.5.4-1198 上可以正常打开...但我遇到了类似的问题,结果发现 Google 日历无法导入 .ics 文件是 UTF-8 和 BOM。现在我将它们作为 UTF-8 从服务器发送,没有 BOM,一切都很好。

【讨论】:

    【解决方案2】:

    我的 Web 应用程序创建的 .ics 文件也有类似的问题。桌面 gmail 对它们的反应很好,但在 android 打开附件导致“无法启动事件”。 Google Calendar 为其邀请邮件生成的 ICS 文件运行良好,因此我进行了一些二进制搜索并找出了问题:我的 .ics 文件缺少 DTSTAMP 属性。该属性是强制性的,所以移动应用程序是错误的抱怨,我只是希望错误消息能提供更多信息。

    经验是:Web 应用程序可能比移动应用程序更松散,因此不要仅仅因为它在其中一个或另一个上都可以正常工作就假设您已正确实施该标准。

    【讨论】:

      【解决方案3】:

      在第一种情况下,您可能希望将 Content-Type 设置为 text/calendar

      在第二种情况下,事情确实有效,可能是因为您传递了一个文件名以 .ics 结尾的内容处置。所以客户端可以从扩展中推断出格式。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多