我正在尝试从android模拟器中删除sms消息并接收下一个错误:
java.lang.IllegalArgumentException: Bad conversation thread id: 15555215554
有人遇到同样的问题,可以帮我解决这个问题吗? 删除消息的代码下一步:
try {
final long thread_id = transactionCursor.getLong(1);
Uri thread = Uri.parse("content://sms/conversations/" + thread_id);
getContentResolver().delete(thread, null, null);
} catch (Exception e) {
System.out.println(e.getMessage());
}
清单文件中的我添加了下一个权限:
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
答案 0 :(得分:1)
是的,Ahmet,你是对的,我从错误信息中理解它,只需从我的代码中更改
try {
final long thread_id = transactionCursor.getLong(transactionCursor.getColumnIndex("thread_id"));
final Uri thread = Uri.parse("content://sms/conversations/" + thread_id);
final int numberOfDeletedMessages = getContentResolver().delete(thread, null, null);
Log.v(TAG, "Number of deleted messages equals to " + numberOfDeletedMessages);
} catch (Exception e) {
Log.e(TAG,e.getMessage(),e);
}
所有作品都成功。