ContentObserver used for SMS [duplicate]

落花浮王杯 提交于 2019-11-30 15:19:30

Here is a code fragment to do this. The key is to use a selection that looks only for "type = outgoing messages".

Also since the content DB can get triggered by any change, keep track (somehow) of what has already been processed.

int THREAD_ID = 0, ADDRESS = 1, DATE = 2, TYPE = 3, BODY = 4, INCOMING = 1, OUTGOING = 2, UNKNOWN = -1;

String[] smsProjection = new String[] {"thread_id", "address", "date", "type", "body"};

ContentResolver cr = context.getContentResolver();

Cursor cursor = context.getContentResolver().query(uri, smsProjection, "type = ? AND date > ?",new String[]{Integer.toString(OUTGOING), Long.toString(lastOutgoingSmsTime)}, null);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!