我想获取特定发件人在手机中的短信列表.这些SMS是从SMS网关发送的,因此我没有发件人的号码.但是,我知道发件人的姓名,例如"Google".
这是我到目前为止所尝试的
final String SMS_URI_INBOX = "content://sms/inbox";
Uri uri = Uri.parse(SMS_URI_INBOX);
String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" };
Cursor cur = getContentResolver().query(uri, projection, "person LIKE'%" + "Google" + "'", null, "date asc");
Run Code Online (Sandbox Code Playgroud)
但是,光标为空.
你快到了
final String SMS_URI_INBOX = "content://sms/inbox";
Uri uri = Uri.parse(SMS_URI_INBOX);
String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" };
Cursor cur = getContentResolver().query(uri, projection, "address LIKE '%Google%'", null, "date asc");
Run Code Online (Sandbox Code Playgroud)
而不是查询"人",查询"地址".SMS网关使用名称作为地址.
| 归档时间: |
|
| 查看次数: |
2560 次 |
| 最近记录: |