确定内容观察者
我有一个内容观察器正在监视呼叫日志:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过为每个调用 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.