获取短信的特定电话号码 [英] Get SMS of specific phone number
本文介绍了获取短信的特定电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,我怎么能读短信进行编程一个具体的数字? 我知道如何使用内容提供商,但不知道读短信,如果我应该用人栏或地址栏或完全不同的方式 请帮忙 谢谢
I am wondering, how can I read sms message for a specific number programmatically? I know how to read sms using content provider but not sure if I should use the "person" column or "address" column or totally different way Please help Thanks
推荐答案
它会列出消息从指定的号码。
It will list out messages from specified number.
Uri mSmsinboxQueryUri = Uri.parse("content://sms/inbox");
Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,new String[] { "_id", "thread_id", "address", "person", "date","body", "type" }, null, null, null);
startManagingCursor(cursor1);
String[] columns = new String[] { "address", "person", "date", "body","type" };
if (cursor1.getCount() > 0) {
String count = Integer.toString(cursor1.getCount());
while (cursor1.moveToNext()){
String address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
if(address.equalsIgnoreCase("number")){ //put your number here
String name = cursor1.getString(cursor1.getColumnIndex(columns[1]));
String date = cursor1.getString(cursor1.getColumnIndex(columns[2]));
String body = cursor1.getString(cursor1.getColumnIndex(columns[3]));
String type = cursor1.getString(cursor1.getColumnIndex(columns[4]));
Log.d("*******", "body="+body);
}
}
}
不过,我碰到内容://彩信,短信/通话/
我认为这将返回的特定号码,直接整个对话的帮助的thread_id
,检查这
But I came across "content://mms-sms/conversations/"
I think it will return directly entire conversation of specific number with the help thread_id
, check this
这篇关于获取短信的特定电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文