确定ContentObserverContentObserver

2023-09-05 04:38:40 作者:哼出我们的小调调﹌

我是看着通话记录这些内容观察员:

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 ***");
    }
}

现在......我怎么能确定这个URI 含量变化的本质:// call_log /通话

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

我要检查,如果缺失发生上述URI的......但是没有办法知道......这似乎适用于查询/删除/插入/上表示URI触发更新的onChange 方法......

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....

任何提示/建议?

推荐答案

你试过注册一个观察者对每个电话的尤里斯?

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

即。如果你有5个电话在通话记录中,注册内容为观察员每次通话开放的我们,或许有初始化与所观察到的呼叫ID观察员。

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.