autojs 区分双卡手机短信内容
时间: 2023-10-05 21:07:43 浏览: 92
在双卡手机上使用 Auto.js 时,您可以通过以下步骤区分短信内容:
1. 获取所有短信列表
```javascript
var smsList = [];
var cursor = context.getContentResolver().query(
android.net.Uri.parse("content://sms"),
[ "_id", "thread_id", "address", "person", "date", "body", "type" ],
null,
null,
"date desc"
);
if (cursor != null) {
while (cursor.moveToNext()) {
var sms = {};
sms.id = cursor.getLong(0);
sms.threadId = cursor.getLong(1);
sms.address = cursor.getString(2);
sms.person = cursor.getLong(3);
sms.date = new Date(cursor.getLong(4));
sms.body = cursor.getString(5);
sms.type = cursor.getInt(6);
smsList.push(sms);
}
cursor.close();
}
```
2. 遍历短信列表,根据 SIM 卡号过滤短信
```javascript
var sim1Number = "SIM卡1的号码";
var sim2Number = "SIM卡2的号码";
var sim1SmsList = [];
var sim2SmsList = [];
for (var i = 0; i < smsList.length; i++) {
var sms = smsList[i];
if (sms.address == sim1Number) {
sim1SmsList.push(sms);
} else if (sms.address == sim2Number) {
sim2SmsList.push(sms);
}
}
```
3. 遍历 SIM 卡短信列表,根据短信内容进行处理
```javascript
var sim1Keyword = "SIM卡1的关键字";
var sim2Keyword = "SIM卡2的关键字";
for (var i = 0; i < sim1SmsList.length; i++) {
var sms = sim1SmsList[i];
if (sms.body.indexOf(sim1Keyword) >= 0) {
// 处理 SIM 卡1的短信
}
}
for (var i = 0; i < sim2SmsList.length; i++) {
var sms = sim2SmsList[i];
if (sms.body.indexOf(sim2Keyword) >= 0) {
// 处理 SIM 卡2的短信
}
}
```
阅读全文