Android:观察已删除线程的短信
我目前编写了一个应用程序,用于观察 content://sms URI 以了解对数据库的任何更改。当添加或删除单个消息时,我的观察者被成功触发,但是,当一次删除整个线程时,不会触发任何通知。有什么办法可以触发这个事件吗?或者也许还有另一个我应该观察的内容提供商?
Uri URI = Uri.parse("content://sms");
String[] columns = {"_id", "date"};
Cursor c = getContentResolver().query(URI, columns, "type=?", new String[]{"1"}, "_id DESC");
Observer observer = new Observer();
c.registerContentObserver(observer);
我的观察者班:
private class Observer extends ContentObserver {
public Observer() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
if (!selfChange) {
// do stuff
// never called when a thread is deleted
}
}
}
I've currently written an app that is observing the content://sms URI for any changes to the database. My observer is successfully being triggered when individual messages are added or removed, however, no notification is triggered when an entire thread is deleted at once. Is there any way to get this event to trigger? Or maybe there's another content provider I should be observing?
Uri URI = Uri.parse("content://sms");
String[] columns = {"_id", "date"};
Cursor c = getContentResolver().query(URI, columns, "type=?", new String[]{"1"}, "_id DESC");
Observer observer = new Observer();
c.registerContentObserver(observer);
And my observer class:
private class Observer extends ContentObserver {
public Observer() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
if (!selfChange) {
// do stuff
// never called when a thread is deleted
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我转而观察 content://mms-sms/conversations 内容提供商。当线程被删除时,该提供程序正确地向我的观察者发出信号。
I switched to observing the content://mms-sms/conversations content provider. This provider properly signals my observer when a thread is deleted.