开发者

Android: Observing SMS for Deleted Threads

开发者 https://www.devze.com 2023-01-27 16:23 出处:网络
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, howev

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开发者_C百科 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
        }
    }
}


I switched to observing the content://mms-sms/conversations content provider. This provider properly signals my observer when a thread is deleted.

0

精彩评论

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

关注公众号