确定内容观察者

发布于 2024-10-07 10:31:07 字数 828 浏览 3 评论 0原文

我有一个内容观察器正在监视呼叫日志:

public class monitorCallLog extends ContentObserver{
    private static final String TAG = "monitorCallLog";
    public monitorCallLog(Handler handler) {
        super(handler);
        // TODO Auto-generated constructor stub
    }
    @Override
    public boolean deliverSelfNotifications() { 
        return false; 
    }
    @Override
    public void onChange(boolean selfChange){
        Log.v(TAG, "[onChange] *** ENTER ***");
        super.onChange(selfChange);
        // Code goes in here to handle the job of tracking....
        Log.v(TAG, "[onChange] *** LEAVE ***");
    }
}

现在...我如何确定此 URI content://call_log/calls 上的更改的性质?

我想检查一下所述 URI 上是否发生了删除...但无法知道...这似乎适用于触发 的所述 URI 上的查询/删除/插入/更新onChange 方法....

有什么提示/建议吗?

I have this content observer that is watching on the Call Log:

public class monitorCallLog extends ContentObserver{
    private static final String TAG = "monitorCallLog";
    public monitorCallLog(Handler handler) {
        super(handler);
        // TODO Auto-generated constructor stub
    }
    @Override
    public boolean deliverSelfNotifications() { 
        return false; 
    }
    @Override
    public void onChange(boolean selfChange){
        Log.v(TAG, "[onChange] *** ENTER ***");
        super.onChange(selfChange);
        // Code goes in here to handle the job of tracking....
        Log.v(TAG, "[onChange] *** LEAVE ***");
    }
}

Now... how can I determine the nature of the change on this URI content://call_log/calls?

I want to check on it if a deletion has occurred on the said URI... but there is no way of knowing...this seems to apply on a query/delete/insert/update on said URI that triggers the onChange method....

any tips/suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谢绝鈎搭 2024-10-14 10:31:07

您是否尝试过为每个调用 Uris 注册一个观察者?

即,如果呼叫日志中有 5 个呼叫,请为每个呼叫 Uri 注册一个内容观察者,也许使用被观察的呼叫的 id 来初始化观察者。

这样,当删除/更新单个调用时,内容提供者的删除方法将发送与单个调用(而不是所有调用)匹配的通知。

我认为这是针对游标列表的非标准方法。我相信内容观察的大多数用途都会requery()光标。

Have you tried registering an observer for each of the call Uris?

i.e. if you have 5 calls in the call log, register a content observer for each call Uri, perhaps having the observer initialised with the id of the call being observed.

That way when an individual call is deleted/updated, the delete method of the content provider will send a notification matching the individual call, rather than all calls.

I think this is a non-standard approach for lists from a cursor. I believe most uses of content observation will requery() the cursor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文