V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
pcatzj
V2EX  ›  Android

求教 Android 日历事件操作中 EventID 的问题

  •  
  •   pcatzj · 2017-02-07 16:20:15 +08:00 · 4287 次点击
    这是一个创建于 2635 天前的主题,其中的信息可能已经有所发展或是发生改变。

    通过intent插入日历事件 上图是 Android 官方文档中通过 intent 跳转到日历来进行插入事件操作的示例代码。

    查看日历事件

    上面这张图是文档中编辑事件的代码,其中需要用到 eventID ,但是插入的过程中并没有指定 eventID 的操作,事后也无法查询到(搜索未果),那么这个 eventID 我应该怎么获取呢?

    3 条回复    2017-02-08 10:36:14 +08:00
    dreamingincode
        1
    dreamingincode  
       2017-02-07 16:44:01 +08:00
    因为用的是 Intent ,你可以尝试 startActivityForResult ,然后在 onActivityResult 里打印出所有返回的内容,寻找有没有包含这个 Id 的 extra 。但是我觉得这又可能没有什么保证(完全看日历应用的编写者?我没见到过相关的约定。

    另外一种方法就是是自己用 ContentResolver 查询了。
    pcatzj
        2
    pcatzj  
    OP
       2017-02-07 16:58:46 +08:00
    @dreamingincode 试了,点击保存,仍然回调 RESULT_CANCEL ,而且 data 是 null
    pcatzj
        3
    pcatzj  
    OP
       2017-02-08 10:36:14 +08:00
    使用 ContentProvider 可以指定 EventID 插入事件,所以使用 Intent 添加有办法做到吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2806 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:18 · PVG 14:18 · LAX 23:18 · JFK 02:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.