开发者

tracing Outgoing SMS

Currently i am using ContentObserver on the Uri

ContentResolver contentResolver = context.getContentResolver();
SMSObserver m_SMSObserver = new SMSObserver(context);
contentResolver.registerContentObserver(Uri.parse("content://sms"), true, m_SMSObserver);

in this manner onChange method call in both the cases i.e incoming and outgoing sms. but i need it only outgoing SMS. and it is noted that

 Uri.parse("content://sms/sent")
开发者_运维技巧 Uri.parse("content://sms/outbox")

not working Kindly help me how i can trace the outgoing message.

thankz.


For those who are still looking for the answer...

I have not figured out the correct URI to scan only the outgoing messages but a good way to distinguish an outgoing from an incoming message is to use the type of the message.

If the type is 2, then it is an outgoing message, and if it is 1, it is an incoming message.

Cursor cur = context.getContentResolver().query(Uri.parse("content://sms"),
                    null, null, null, null);

int type = cur.getInt(cur.getColumnIndex("type"));
if(type == 1){
  //Processing the incoming message
}else if(type == 2){
  //Processing the outgoing message
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜