开发者

Determine the ContentObserver

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() { 
  开发者_StackOverflow      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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜