BroadcastReceiver的为Android日历事件 [英] BroadcastReceiver for Android Calendar events

查看:332
本文介绍了BroadcastReceiver的为Android日历事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个BroadcastReceiver监听像插入,编辑活动,删除到原生的Andr​​oid日历(ICS及以上)。所以每当这些事件之一发生该应用应该能够在至少知道,这些事件的发生。

I am trying to write a BroadcastReceiver that listens to events like insert, edit, delete to the native android calendar (ICS and above). So whenever one of these events occur the app should be able to at the least know that these events occurred.

任何人有一个想法,如何做到这一点,或任何引用链接。

Any one has an idea, how to do this or any reference links.

我已经写了,从BroadcastReceiver的扩展自己的broadcasterReceiver类。想不通清单中的值,例如,目前我有这里面是不工作:

I have written my own broadcasterReceiver class that extends from BroadcastReceiver. Can't figure out the values in the manifest like, currently I have this which is not working:

 <receiver
    android:name=".NativeEventChangeReceiver">
     <intent-filter>
        <action android:name="android.intent.action.EDIT"/>
        <action android:name="android.intent.action.INSERT"/>
        <action android:name="android.intent.action.DELETE"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="vnd.android.cursor.dir/event"/>
     </intent-filter>
  </receiver>

干杯,

编辑1: 有谁知道一个适当的字符串数据标签?我想这还需要在意向过滤器。

Edit 1: Does anyone know a proper string for the data tag?, I think this is also required in the intent-filter.

编辑2: 关于与C​​ontentObserver工作的任何提示?

Edit 2: Any hints about working with ContentObserver?

推荐答案

终于找到了大量的阅读后的解决方案,这可能帮助其他寻找一个类似的解决方案。

Finally found the solution after a lot of reading, this may help other finding a similar solution.

在清单,你需要写这些线路才能够捕获更改:

In the Manifest, you need to write these lines to be able to capture the changes:

<receiver
   android:name=".NativeEventChangeReceiver">
        <intent-filter>
            <action android:name="android.intent.action.PROVIDER_CHANGED"/>
            <data android:scheme="content"/>
            <data android:host="com.android.calendar"/>
        </intent-filter>
</receiver>

干杯,

这篇关于BroadcastReceiver的为Android日历事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆