0

我正在使用 android 发送消息,SmsManager.sendTextMessage(..) 但是在阅读 SMS 内容提供程序列时,我得到的类型列值 1 应该是 2 用于发送消息,甚至在设备默认消息传递应用程序上,我发送的消息显示为已接收。

我用来发送消息的代码是

public static final String SMS_URI = "content://sms";
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(address.get(i), null, messagetosend, null, null);
ContentResolver contentResolver = getContentResolver();

ContentValues values = new ContentValues();
values.put(ADDRESS, address.get(i));
values.put(BODY, messagetosend);
contentResolver.insert(Uri.parse(SMS_URI), values);

我正在使用这段代码在 Logcat 上打印值:

Uri allMessages = Uri.parse("content://sms/");
//Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same
Cursor cursor = this.getContentResolver().query(allMessages, null, null, null, null);

while (cursor.moveToNext()) {
    for (int i = 0; i < cursor.getColumnCount(); i++) {
        Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
    }
    Log.d("One row finished", "**************************************************");
}
4

1 回答 1

1

尝试改变

public static final String SMS_URI = "content://sms";

public static final String SMS_URI = "content://sms/sent";

你也可以添加

values.put("type", 2);
于 2012-12-05T10:25:27.580 回答